Binding NIC cards in Ubuntu to create redundancy

Posted by on January 11, 2012 in Operating Systems, Ubuntu | 0 comments

If you have 2 network interfaces in Ubuntu, you may want to bind them together to create redundancy. If you bind two NICs together, 1 can be unplugged, or unavailable to the network and the IP address will still broadcast through the other NIC. So here’s how to do it in Ubuntu.

Install ifenslave:

sudo apt-get install ifenslave

Add some settings into the /etc/modules file:

echo “bonding mode=active-backup miimon=100 primary=eth0” >> /etc/modules

Note that “active-backup” means that the second NIC is not used unless the first becomes unavailable. You can change this if load balancing traffic to the machine is your goal.

Finally change the /etc/network/interfaces file:

# The primary network interface
auto bond0
iface bond0 inet static
address 192.168.1.X1
post-up ifenslave bond0 eth0 eth1
pre-down ifenslave -d bond0 eth0 eth1

# The secondary network interface
auto bond0:0
iface bond0:0 inet static
address 192.168.1.X2

Note that I used different IP addresses for each NIC. They both broadcast then, and the machine is available at X1 and X2 event though the NIC’s are bonded.

Restart your machine after you complete these changes. I’ve had very little success having the changes be applied correctly any other way. Once completed, you will be able to unplug either cable and still have your connection work. When unplugging, there will be a slight delay while the other card takes over the connections.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Comment

Your email address will not be published. Required fields are marked *