Network

Bonding

By default the failback is not configured but you may specify that using "primary=eth0"

  • Check the status for bond connection: cat /proc/net/bonding/bond0
  • Display the bonding mode: cat /sys/class/net/bond0/bonding/mode
  • View all existing bonds, even if they are not up: cat /sys/class/net/bonding_masters
  • Change the active slave: ifenslave -c bond0 eth1

IP Forwarding

  • Enable IP Forwarding on the fly: sysctl -w net.ipv4.ip_forward=1 or echo 1 > /proc/sys/net/ipv4/ip_forward
  • Permanent setting:

vi /etc/sysctl.conf

net.ipv4.ip_forward = 1

sysctl -p

  • Init script

vi /etc/sysconfig/network

FORWARD_IPV4=true

/etc/init.d/network restart

  • Verification: cat /proc/sys/net/ipv4/ip_forward

netstat

  • Display interface table statistics: netstat -i
  • Continuous interface table statistics listing: netstat -ic or watch -n1 netstat -i
  • Display networking statistics (like SNMP): netstat -s
  • Display the number of open connections per IP: netstat -ntu | awk -F"[ :]+" 'NR>2{print $6}' | sort | uniq -c | sort -rn
  • Display the number of open connections by status: netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n

Commands:

  • Show driver information: ethtool -i eth0
  • Add an IP on a interface: ifconfig eth0 192.168.1.20 netmask 255.255.255.0 or ip addr add 192.168.1.23/24 dev eth0
  • Add default gateway: route add default gw 192.168.1.1 or ip route add default via 192.168.1.1 dev eth0
  • Add a static route: route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.1 or ip route add 192.168.2.0/24 via 192.168.1.1
  • Delete a static route: route del -net 192.168.2.0 netmask 255.255.255.0 or ip route del 192.168.2.0/24