Channel bonding (also known as NIC Teaming) enables multiple network interfaces to be joined together to form a single channel that gives higher bandwidth and redundancy. Channel bonding in CentOS is provided by the bonding
kernel module and it supports different policies for load balancing and fault tolerance.
This article explains how to create a channel bond interface named bond0
with two network interfaces eth0
and eth1
. The two interfaces will operate in an active-backup configuration for fault tolerance.
Step 1: Configure bonding kernel module
Create a file named bond.conf
in the /etc/modprobe.d/
directory and add the contents as below
# vi /etc/modprobe.d/bond.conf alias bond0 bondingThe config file /etc/modprobe.conf used in earlier versions of CentOS is deprecated in CentOS 6. The config file should now reside in the /etc/modprobe.d/ directory. The file name can be anything with a .conf extension
Step 2: Create channel bonding interface bond0
Create a file named ifcfg-bond0
in /etc/sysconfig/network-scripts/
directory
# vi /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 BOOTPROTO=none IPADDR=10.17.40.18 NETMASK=255.255.255.0 GATEWAY=10.17.40.254 ONBOOT=yes BONDING_OPTS="mode=1 primary=eth0 miimon=100"
Set an appropriate IP address, netmask and gateway for your environment.
The BONDING_OPTS directive specifies the parameters for the bonding driver.
-mode parameter is used to set the bonding policy, in this case it is set to 1 for an active-backup policy.
-primary parameter sets the primary network interface as eth0
-miimon parameter sets the link check interval to 100 milliseconds
For a complete list of bonding module parameters run:
# modinfo bonding
Bonding parameters can be set also on the .conf file in /etc/modprobe.d/ directory which will then be applied to all channel bonds in the system.
If you create multiple bonds in your system, specifying the bonding module parameters in the bond interface configuration file gives you the flexibility to have different bonding policies and configuration for each bond.
Step 3: Configure eth0 interface as a slave for bond0
Edit ifcfg-eth0
script in /etc/sysconfig/network-scripts/
directory and add MASTER
and SLAVE
directives as below:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 MASTER=bond0 SLAVE=yes BOOTPROTO=none HWADDR=2C:44:DF:83:4E:84 ONBOOT=yes USERCTL=no
Step 4: Configure eth1 interface as a slave for bond0
Edit ifcfg-eth1
script in /etc/sysconfig/network-scripts/
directory and add MASTER
and SLAVE
directives as below:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth1 MASTER=bond0 SLAVE=yes BOOTPROTO=none HWADDR=2C:44:DF:83:4E:85 ONBOOT=yes USERCTL=no
Step 5: Load bonding module and enable bond interface
The easiest way to do this is to restart the system which will load the bonding kernel module and will also enable the channel bonding interface in the next boot.
This can also be done manually without restarting the server using the commands below
# modprobe bonding # ifconfig bond0 up # service network restart
Step 6: Verify bonding status
To verify bonding details, list the contents of file /proc/net/bonding/bond0
# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008) Bonding Mode: fault-tolerance (active-backup) Primary Slave: eth0 (primary_reselect always) 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: 2C:44:DF:83:4E:84 Slave Interface: eth1 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 2C:44:DF:83:4E:85
The above output shows bond0 is running in active-backup mode with two slaves eth0 and eth1. Only one of the interfaces will be active at a time, in this case it is eth0. To display the status of the bond0 interface run
# ifconfig bond0 bond0 Link encap:Ethernet HWaddr 2C:44:DF:83:4E:84 inet addr:10.17.40.18 Bcast:10.17.40.255 Mask:255.255.255.0 UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:9116751 errors:0 dropped:0 overruns:0 frame:0 TX packets:5964547 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2008848605 (1.8 GiB) TX bytes:2360365182 (2.1 GiB)