Configure NIC bonding in CentOS 7 / RHEL 7
NIC bonding is an efficient method to increase the available bandwidth of a server. NIC (Network Interface Card) bonding is also known as Network bonding. It is a combination of two or more NICs into a single bond interface. Two NICs appear to be the same physical device, and hence they have same MAC address when they are bonded.
Linux uses a module called Bonding to allow the users to combine multiple network interfaces. So, first of all, we need to enable the mentioned kernel module. In CentOS/RHEL it is not enabled by default.
Please check the module bonding is already enabled.
lsmod | grep bonding
If it is not enabled, please enable it using the following command.
modprobe bonding
Run the following command to get the bonding module information.
modinfo bonding
Here I am combining two network interfaces of a CentOS 7 machine, namely:
enp0s3
enp0s4
First, we need to create bond0 configuration file:
vim /etc/sysconfig/network-scripts/ifcfg-bond0
Add the following into it:
DEVICE=bond0 NAME=bond0 TYPE=Bond BONDING_MASTER=yes IPADDR=192.168.1.10 PREFIX=24 ONBOOT=yes BOOTPROTO=none BONDING_OPTS="mode=5 miimon=100"
Here, BONDING_OPTS describes the bonding mode.
Types of Network Bonding
mode=0 (balance-rr)
Round-robin policy: It the default mode. It transmits packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
mode=1 (active-backup)
Active-backup policy: In this mode, only one slave in the bond is active. The other one will become active, only when the active slave fails. The bond’s MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance.
mode=2 (balance-xor)
XOR policy: Transmit based on [(source MAC address XOR’d with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.
mode=3 (broadcast)
Broadcast policy: Transmits everything on all slave interfaces. This mode provides fault tolerance.
mode=4 (802.3ad)
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.
mode=5 (balance-tlb)
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.
mode=6 (balance-alb)
Adaptive load balancing: It includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.
Edit the NIC interface files
For enp0s3
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
Add the following into it.
TYPE=Ethernet BOOTPROTO=none DEVICE=enp0s3 ONBOOT=yes HWADDR="28:f1:0e:27:9a:da" MASTER=bond0 SLAVE=yes
For enp0s4
vim /etc/sysconfig/network-scripts/ifcfg-enp0s4
Add the following into it.
TYPE=Ethernet BOOTPROTO=none DEVICE=enp0s4 ONBOOT=yes HWADDR="a0:d3:7a:91:91:00" MASTER=bond0 SLAVE=yes
Then restart Network Service.
systemctl restart network
Test NIC Bonding
cat /proc/net/bonding/bond0
That’s it!
If you like this post and wish to receive more articles from us, please like our FB page: Grepitout
Your suggestions and feedbacks will encourage us and help to improve further, please feel free to write your comments.
For more details on our services, please drop us an E-mail at info@grepitout.com
Add Comment