Monday, June 1, 2009

Linux Bonding (aka NIC teaming)

One question that often comes up when transferring from the Windows to the Linux world is "How do I setup NIC teaming?". The answer is "bonding". A great document on what is involved can be found at The Linux Foundation.
"The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical bonded interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed." - The Linux Foundation
For those seeking a shortcut, below are steps to configure bonding using initscripts on Redhat EL that I have successfully used in the past:

1. Add an alias to /etc/modprobe.conf
alias bond0 bonding
options bond0 mode=active-backup miimon=100

This example loads the bonding module with the option for active-backup (failover teaming). The miimon setting is the time in ms between health checks of the interfaces.

2. In /etc/sysconfig/network-scripts edit the ifcfg-ethX files for each of the NICs to be bonded.
example: ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

3. Next, create a script file for bond0 called ifcfg-bond0. In this example I am using a static IP config, but DHCP can be used as well (if you really wanted to).
example: ifcfg-bond0
DEVICE=bond0
IPADDR=xxx.xxx.xxx.xxx
NETWORK=xxx.xxx.xxx.xxx
BROADCAST=xxx.xxx.xxx.xxx
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
4. Finally run as root one the following commands to restart the network subsystem:
/etc/rc.d/init.d/network restart
or
service network restart
The new bonded interface, bond0, should now be alive and functioning. Before you call it a day, I recommend running through some failover tests to ensure this new HA setting of your server functions as planned. On a personal note, I always document the steps and results of my failover testing. This can be useful down the road if something goes wrong. There is nothing worse than finding out you forgot a setting the hard way!

As a follow up, I plan on posting a brief howto on setting up VLAN tagging. This is useful for those of us who have limited NICs but need to connect to multiple VLANs. It also works well with bonded interfaces.

0 comments:

Post a Comment