How to configure NIC Bonding
(NIC Teaming) in Linux
Ethernet
Channel Bonding enables two or more NIC to a single virtual NIC card which may
increase the bandwidth and provides redundancy of NIC card. This is a great way
to achieve redundant links, fault tolerance or load
balancing network in production system. There are almost 0-6 modes
of Channel Bond types, but widely used are mode 0 (load balancing-rr) and mode
1(active backup).
Step 1. Create Bonding Channel. Add below line to
load the bonding module in the kernel
# cd /etc/modprobe.d
# vi bonding.conf
alias bond0 bonding
# vi bonding.conf
alias bond0 bonding
For load balancing
(round-robin): mode = 0
modeprobe.d: contains .conf file which specify module options, create module aliases, and override the usual behavior of modprobe for modules with special requirements.
miimon: Specifies the MII link monitoring frequency in millisecond. This determines how often the link state of each salve is inspected for link failure. A value of 0 disables whereas 100 is good starting point.
mode: Specifies one of the bonding policies. The default is balance-rr (round robin)
Primary: A string (eth0,eth1) specifying which slave is the primary device. The specified device will always be the active slave while it is available. Only when primary is off-line, alternate devices be used. Primary option is only valid for active-backup mode.
modeprobe.d: contains .conf file which specify module options, create module aliases, and override the usual behavior of modprobe for modules with special requirements.
miimon: Specifies the MII link monitoring frequency in millisecond. This determines how often the link state of each salve is inspected for link failure. A value of 0 disables whereas 100 is good starting point.
mode: Specifies one of the bonding policies. The default is balance-rr (round robin)
Primary: A string (eth0,eth1) specifying which slave is the primary device. The specified device will always be the active slave while it is available. Only when primary is off-line, alternate devices be used. Primary option is only valid for active-backup mode.
Step 2: Creating Channel
Bonding Interface
# vi
/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.2.110
NETWORK=192.168.2.0
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=none
USECTL=no
BONDING_OPTS=”mode=1
miimon=100”
For
round-robin, Set mode=0
Step 3. Configure channel
bonding interface
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
USERCTL: Indicates that can user control this
device (here it’s no)
MASTER: Is this device master? Then what it is (here it’s bond0)
SLAVE=Is this device acting as slave?
BOOTPROTO: what about getting IP address? DHCP or static
MASTER: Is this device master? Then what it is (here it’s bond0)
SLAVE=Is this device acting as slave?
BOOTPROTO: what about getting IP address? DHCP or static
# vi
/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
Start the service
#
service network restart
Check status of bonding
interface:
# cat
/proc/net/bonding/bond0
Ethernet
Channel Bonding Driver: v3.4.0-1 (October 7, 2008)
Bonding Mode: adaptive load
balancing
Primary
Slave: None
Currently
Active Slave: eth0
MII
Status: up
MII
Polling Interval (ms): 100
Up
Delay (ms): 0
Down
Delay (ms): 0
Slave
Interface: eth0
MII
Status: up
Speed:
1000 Mbps
Duplex:
full
Link
Failure Count: 0
Permanent
HW addr: 00:0c:29:e7:5b:45
Slave
Interface: eth1
MII
Status: up
Speed:
1000 Mbps
Duplex:
full
Link
Failure Count: 0
Permanent
HW addr: 00:0c:29:e7:5b:4f
[root@localhost
~]#
Check:
# ifconfig
eth1 down
#
ifconfig eth1 up
To
list the currently Configured bonds:
[root@localhost
~]# cat /sys/class/net/bonding_masters
bond0
[root@localhost
~]#
Removing
Bonding:
#
ifconfig bond0 down
#
rmmod bonding
#
service network restart
[root@localhost
~]# ifconfig -a
bond0 Link encap:Ethernet HWaddr 00:0C:29:E7:5B:45
inet addr:192.168.2.110 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MASTER
MULTICAST MTU:1500 Metric:1
RX packets:4287 errors:0 dropped:0
overruns:0 frame:0
TX packets:36542 errors:0 dropped:0
overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:379270 (370.3 KiB) TX bytes:2201569 (2.0 MiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:E7:5B:45
UP BROADCAST RUNNING SLAVE
MULTICAST MTU:1500 Metric:1
RX packets:2250 errors:0 dropped:0
overruns:0 frame:0
TX packets:18305 errors:0 dropped:0
overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:201110 (196.3 KiB) TX bytes:1105341 (1.0 MiB)
eth1 Link encap:Ethernet HWaddr 00:0C:29:E7:5B:4F
UP BROADCAST RUNNING SLAVE
MULTICAST MTU:1500 Metric:1
RX packets:2037 errors:0 dropped:0
overruns:0 frame:0
TX packets:18237 errors:0 dropped:0
overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:178160 (173.9 KiB) TX bytes:1096228 (1.0 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436
Metric:1
RX packets:1147 errors:0 dropped:0
overruns:0 frame:0
TX packets:1147 errors:0 dropped:0
overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2610580 (2.4 MiB) TX bytes:2610580 (2.4 MiB)
[root@localhost
~]#
Note: Here are some extra steps for Red Hat Linux 6 that need to perform
before creating the channel.
Check if Bonding
Kernel Module is installed
In
Red Hat Enterprise Linux 6, the bonding module is not loaded by default. You
can load the module by issuing the following command as root:
[root@localhost
~]# modprobe --first-time bonding
To
display information about the module, issue the following command:
[root@localhost
~]# modinfo bonding
