Networking Bonding in RHEL/CentOS 7: Combining multiple NICs into one

Last updated on March 12th, 2018 at 07:43 pm

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.

 

Installation

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-bond0
DEVICE=bond0
TYPE=Bond
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
BONDING_OPTS=”mode=5 miimon=100″

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,

TYPE=Ethernet
BOOTPROTO=none
DEVICE=enp0s3
ONBOOT=yes
HWADDR=”23:03:56:bh:56:9g”
MASTER=bond0
SLAVE=yes

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.

 

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter | Google Plus

Donate us some of you hard earned money:

Linux TechLab is thankful for your continued support.

Shusain

Passionate about Linux & open source. Loves to learn, read & write about Linux as well as new technologies.

You may also like...

2 Responses

  1. deoren says:

    Thanks for posting this! I actually have to do this for a new CentOS 7 server that we just finished racking, so your timing is very fortunate for us. 🙂

    I notice that you loaded the bonding module via modprobe early in the process, but didn’t see you mention any way of having that module be loaded on boot. Is the module automatically loaded at boot based off of the new ifcfg-bond0 file that was created as part of this tutorial?

  2. anand says:

    The rc.modules is recommended to use, not rc.local because rc.modules gets executed earlier in the boot process…

Leave a Reply