Networking Bonding in RHEL/CentOS 7: Combining multiple NICs into one
When hosting a successful & busy websites or operating a critical server, high availability & redundancy are major factors to consider. To achieve high availability & redundancy, backup of the server & server clusters are prepared. One other thing that is used for HA/redundancy is Network Bonding.
Network Bonding refers to combining of more than one NIC into a single NIC for the purpose of HA/redundancy or load balancing. When network bonding is achieved and one of the NICs fail, the load will be transferred to next NIC in the bonding or we can even also configure it for load balancing.
In this tutorial, we are going to create network bonding for two interfaces on RHEL/CentOS 7 servers.
To create a network bond between NICs, we will require bonding module. To load the bonding module into the system, run
|$ modprobe bonding
Once the module has been loaded, we will create a file for bonding interface ‘ifcfg-bind0’ in ‘/etc/sysconfig/network-scripts’ directory.
Configuring Bond interface
Goto ‘/etc/sysconfig/network-scripts’ & create bond file with following content,
|$ cd /etc/sysconfig/network-scripts
$ vi ifcfg-bond0DEVICE=bond0
Here, mode=5 means network bond will provide fault tolerance & load balancing as well. Details of all available modes for network bonding are mentioned below,
mode=0 (Balance Round Robin)— round-robin mode for fault tolerance and load balancing.
mode=1 (Active backup)— Sets active-backup mode for fault tolerance.
mode=2 (Balance XOR)— Sets an XOR (exclusive-or) mode for fault tolerance and load balancing.
mode=3 (Broadcast)— Sets a broadcast mode for fault tolerance. All transmissions are sent on all slave interfaces.
mode=4 (802.3ad)— Sets an IEEE 802.3ad dynamic link aggregation mode. Creates aggregation groups that share the same speed & duplex settings.
mode=5 (Balance TLB)— Sets a Transmit Load Balancing (TLB) mode for fault tolerance & load balancing.
mode=6 (Balance ALB)— Sets an Active Load Balancing (ALB) mode for fault tolerance & load balancing.
Next step is to configure network interfaces i.e. ifcfg-en0s3 &en0s5 , for the bonding.
Configuring network interfaces
Make changes to the both interfaces file & add parameters “MASTER” & “SLAVE” to it, so that it looks like,
Save both files & restart the networking services on the system,
|$ systemctl restart network
We can now run ‘ifconfig’ command to verify our newly created bonding interface or we can also check the bonding by running the following,
|$ cat /proc/net/bonding/bond0
This will provide complete information about bonding interface.
Testing fault tolerance
To test if the network bonding is working or not, bring one of the network interfaces down. To do so, run
|$ ifdown en0s3
& verify by making a http or ssh request to the server via the bonding interface IP address, network should be working just fine. Further we can also check which interface is working & which is down by running the above command i.e
|$ cat /proc/net/bonding/bond0
Note:- For persistent loading of module at the system boot, run the following command,
$ echo modprobe bonding >> /etc/rc.modules
$ chmod +x /etc/rc.modules
This concludes our tutorial on network bonding. Please mention your queries/comments in the comment box below.