Ethernet

From Alessandro's Wiki

general Linux commands

ifconfig -a
  • attivare la scheda di rete eth0 (senza script di ifup/ifdown)
ifconfig eth0 up
  • disattivare la scheda di rete eth0 (senza script di ifup/ifdown)
ifconfig eth0 down
  • Chiedere in broadcast un indirizzo ip su eth0 (!!!)
dhclient eth0
  • Sapere se hai problemi con la scheda (il NIC)
# tail -50 /var/log/messages |grep -A4 eth0
NETDEV WATCHDOG: eth0: transmit timed out
Mar 26 14:21:39  kernel: eth0: transmit timed out, tx_status 00 status e000.
Mar 26 14:21:39 kernel:   diagnostics: net 0cf2 media 8880 dma 000000a0 fifo 0000
Mar 26 14:21:39 kernel:   Flags; bus-master 1, dirty 1048374(6) current 1048390(6)
Mar 26 14:21:39 kernel:   Transmit list 16c7f5c0 vs. d6c7f5c0.
  • scanneriz1zare una rete privata:
for a in `seq 1 254`; do echo -n -e "\r   $a   ";ping -c1 192.168.1.$a|grep "bytes from "; done

host scanning

  • nmap is the master tool, then everything follows.
nmap <host>
nmap -sS -p0-65535 -P0 -T4 --osscan_limit --osscan_guess --host_timeout 15m --max-retries 0 --min_parallelism 100 --max_parallelism 500 -O -oX -V <host>

subnet scan

  • this command will scan all host in the 10.10.10.0/24 subnet
nmap -sP 10.10.10.0-254
nmap -sP 192.168.82.0/24

Cisco

  • para conectar un host directo a un puerto de un router (Cisco)
cisco-6500#
cisco-6500#conf t
cisco-6500(config)#int gi3/44
cisco-6500(config-if)#spanning-tree port ?
 port-priority  portfast
cisco-6500(config-if)#spanning-tree portfast ?
 disable  Disable portfast for this interface
 trunk    Enable portfast on the interface even in trunk mode
 <cr>
cisco-6500(config-if)#spanning-tree portfast


Linux Routing Table

  • example data
uplink1_ip=192.168.0.2
uplink1_gw=192.168.0.1
uplink1_if=ens31

uplink2_ip=1.2.3.4
uplink2_gw=1.2.3.1
uplink2_if=ens32
  • show main table (and save)
ip route show table main
  • create the new table for uplink2
echo 202 uplink2 >> /etc/iproute2/rt_tables
ip route add 1.2.3.1/32 dev ens32 src 1.2.3.4 table uplink2
ip route add default via 1.2.3.1 table uplink2
ip rule add from 1.2.3.4 table uplink2