In this post, I will show you how to bond two NIC interfaces together on Centos 7 using the bond 5 mode option while using a single static IP. I’m also assuming you have firewalld configured in this tutorial which is why I have included the zone definitions below.
I have chosen the bond 5 mode as it is my favorite. What is bond 5?
Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.
- Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.
As you can see, bond 5 acts as a load balancer between the NIC’s and also as a failover should a NIC fail. Let’s get started.
First, navigate to the /etc/sysconfig/network-scripts/ directory by typing the following command.
Next, let’s create a new interface file called ifcfg-bond0 using your favorite editor.
Paste the following lines into this new file and save:
DEVICE=bond0 TYPE=Bond NAME=bond0 BONDING_MASTER=yes BOOTPROTO=static ONBOOT=yes IPADDR=XX.XXX.XX.XXX PREFIX=24 GATEWAY=XX.XXX.XX.XXX DNS1=XX.XX.XX.XX DNS2=XX.XX.XX.XX BONDING_OPTS="mode=5 miimon=100" ZONE=public
Be sure to replace the (X’s) with your ISP information. Also, be sure to use the correct zone in your setup.
Next, let’s update the two interfaces you want to use as the slave for the newly created bond interface above. Let’s open each one again with your favorite editor and make the following changes.
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=enp7s0 UUID=t87395473-9h3i-9437-10g4-83jd83jdjf7473 DEVICE=enp7s0 ONBOOT=yes MASTER=bond0 SLAVE=yes ZONE=public
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=enp10s0 UUID=t87334s-953i-9327-57e4-jf73hdu73yjhdjfy3 DEVICE=enp10s0 ONBOOT=yes MASTER=bond0 SLAVE=yes ZONE=public
You should have noticed the following lines in each file.
ONBOOT=yes MASTER=bond0 SLAVE=yes
Please note that I’m not 100% sure if the zone is needed in the two slave interface files, but I have added it to be 100% sure it works correctly. Feel free to test without the zone definition here if you like, as it is already defined in the bond interface. If you test it without the zone definition here, please let me know how it went.
Restart your network.
systemctl restart network
Now let’s check our bond status.
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: transmit load balancing Primary Slave: None Currently Active Slave: enp10s0 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: enp7s0 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: e0:55:88:e0:32:ee Slave queue ID: 0 Slave Interface: enp10s0 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: e0:30:88:e0:47:03 Slave queue ID: 0
As you can see, the new bond interface is working and the active interface is enp10s0.