Most servers ship with dual network interfaces nowadays in order to have redundant net access. Of course, having two separate cards is preferable, but even if it's a dual NIC installed why not use both ports? A fail-over solution has been the primary concern for me, in other words if one NIC goes down the other NIC should automatically take over. There are quite a lot of terms describing this and some call it bonding other teaming. Whatever it is called this is how I configured fail-over for two NICS on Debian.
apt-get install modutils ifenslave-2.6
Create the file /etc/modprobe.d/aliases-bond and add these line
# Bonding of NICs alias bond0 bonding options bond0 mode=1 arp_interval=2000 arp_ip_target=192.168.0.2
Mode 1 is active-backup where one interface is active and one is in standby mode, ready to become the active interface in case the other one fails. The arp_ip_target should point to one or more reliable servers or routers as they will be pinged every 2 seconds (2000 ms). In this case it's just the gateway but up to 16 ip-adresses can be specified. One can use miimon for checking the connectivity state as percieved by the device, arp checks connectivity to other host on the network. According to the docs they should not be used together, use either miimon or arp. To use miimon instead change the lines above to:
# Bonding of NICs alias bond0 bonding options bond0 mode=1 miimon=100
During debian installation I choose eth1 as the default nic and that is the reason why eth1 is entered before eth0 in the ifenslave command below. My /etc/network/interfaces file looks like this:
# The primary network interface allow-hotplug eth0 allow-hotplug eth1 auto bond0 iface bond0 inet static pre-up ifconfig bond0 up pre-up ifconfig eth1 up pre-up ifconfig eth0 up address 192.168.1.100 netmask 255.255.255.0 gateway 192.168.1.2 up ifenslave bond0 eth1 eth0
Some have added these extra lines to /etc/network/interfaces as they have experienced that the command /etc/init.d/networking stop hanged their box, but I have never experienced any problems.
down ifconfig eth1 down down ifconfig eth0 down down ifenslave -d bond0 eth1 eth0
Further reading: http://www.kernel.org/pub/linux/kernel/people/marcelo/linux-2.4/Documentation/networking/bonding.txt
A more recent version of the documentation: http://www.kernel.org/doc/Documentation/networking/bonding.txt
Comments
Post new comment