Wednesday, June 15, 2011

Bonding (Teaming) NICs in Linux

This example assumes you have two interfaces and want to use them in a 'fail-over' setup, where if one cable dies, the kernel will automatically switch to using the other cable.
You need the following files in /etc/sysconfig/network-scripts/ :
ifcfg-eth0
ifcfg-eth1
ifcfg-bond0
 
1: Edit bond0 configuration file:
If ‘ifcfg-bond0’ is not there, create it  "# vi /etc/sysconfig/network-scripts/ifcfg-bond0"
Edit bond0 using VI
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
Replace above IP address with your actual IP address. Save file and exit VI.
2: Modify eth0 and eth1 config files:
Open eth0 and eth1 files VI text editor and make sure file read as follows
ifcfg-eth0 ‘  file:
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
 
ifcfg-eth0 ‘ file:
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
Save files and exit VI.
 
3: Load bond driver/module
Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up.
Open /etc/modprobe.conf file in VI and append bellow two lines
alias bond0 bonding
options bonding miimon=100 mode=0
Save file and VI
(Linux bonding options explained)
**********************************************************************************
miimon
Specifies the MII link monitoring frequency in milliseconds. This determines how often the link state of each slave is inspected for link failures. A value of zero disables MII link monitoring. A value of 100 is a good starting point.
The use_carrier option, below, affects how the link state is determined. See the High Availability section for additional information. The default value is 0.
mode
Specifies one of the bonding policies. The default is balance-rr (round robin).
 
**********************************************************************************
 
For a complete reference please click here.
4: Test configuration
First, load the bonding module # modprobe bonding and restart networking service

No comments: