Ethernet bonding is a method of combining (merging) two or more network interfaces into a single virtual NIC card, which may increase bandwidth and provide NIC card redundancy.
Linux allows binding multiple network interfaces using a special kernel module called bonding. This feature is already enabled on Linux, so we can create a new virtual interface called bonding. We have two NIC cards ens33 and ens34. This post shows the process on RHEL 7 and CentOS 7.
table of Contents
- 1) Enable the binding module
- 2) Create a binding channel interface
- 3) Configure the physical interface
- 4) Activate the binding channel
- in conclusion
1) Enable the binding module
In the first step, you need to check if the binding module is enabled. You can check with the following command
# modinfo bonding modinfo: ERROR: Module alias bonding not found.
If it does not exist, you can use the following command:
# modprobe --first-time bonding
You can check again. You will get the following results
# modinfo bonding
You can see that the command gives us results, and you can view the description line.
2) Create a binding channel interface
We will first
/etc/modprobe.d/ table of Contents. The name can be anything you like, as long as it ends with a .conf extension. This is the configuration file for the driver named bonding
# vim /etc/modprobe.d/bonding.conf alias bond0 bonding
Insert content on it, save and exit. For each configured channel bonding interface, your
Now we can create a channel binding interface. To do this, we need to
/etc/sysconfig/network-scripts/ Directory called
ifcfg-bond0 As the alias created earlier. You must note that we operate on folders containing network interface files.
# vim /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 NAME=bond0 TYPE=Bond BONDING_MASTER=yes IPADDR=192.168.43.100 PREFIX=24 ONBOOT=yes BOOTPROTO=none BONDING_OPTS="mode=1 miimon=100"
Note the instruction BONDING_OPTS line, the binding uses a variety of options and modes. The pattern can be:
- Mode 0 Either Balance rr: Set up a round robin strategy for fault tolerance and load balancing.
- Mode 1 Either Active backup: Set an active backup strategy for fault tolerance.
- Mode 2 Either Balanced XOR: Set XOR (Exclusive OR) mode for fault tolerance and load balancing.
- Mode 3 Either broadcast: Set a broadcast policy for fault tolerance. All transmissions are sent on all slave interfaces.
- Mode 4 Either 802.3ad: Set IEEE 802.3ad dynamic link aggregation policy. Create aggregate groups that share the same speed and duplex settings.
- Mode 5 Either Balance sheet: Set up a TLB strategy for fault tolerance and load balancing. Outgoing traffic is distributed based on the current load on each slave interface. The current slave is receiving incoming traffic. If the receiving slave fails, the other slave will take over the MAC address of the failed slave. This mode applies only to local addresses known by the kernel binding module, so it cannot be used behind bridges to virtual machines.
- Mode 6 Either Balance white: Set Adaptive Load Balancing (ALB) strategies for fault tolerance and load balancing. Includes transmit and receive load balancing for
The options can be:
- miimon =time_in_milliseconds: Shows (in milliseconds) how often the link status check link failed. This is useful if high availability is required, as using MII to verify that the NIC is active
- arp_interval = time_in_Milliseconds: Specify (in milliseconds) the frequency of ARP monitoring. If you use this setting in Mode 0 or Mode 2 (both load balancing modes), the network switch must be configured to distribute packets evenly across the NIC.
3) Configure the physical interface
The next step is to edit the physical interface for binding by adding the following
SLAVE=yes Configuration file directive. This means that the channel binding interface is the master interface, and the interface to be bound is called the slave interface. The configuration file for each channel binding interface is almost the same, you need to comment out or delete the ip address, netmask, gateway, and hardware address of each file, as the settings should only come from above the ifcfg-bond0 file. Make sure to add MASTER and SLAVE configurations in these files.
For the ens33 interface, we will perform the following configuration
# vim /etc/sysconfig/network-scripts/ifcfg-ens33 DEVICE=ens33 NAME=bond0-slave TYPE=Ethernet BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes
For the ens34 interface, the file should look like this
# vim /etc/sysconfig/network-scripts/ifcfg-ens34 DEVICE=ens34 NAME=bond0-slave TYPE=Ethernet BOOTPROTO=none ONBOOT=yes MASTER=bond0 SLAVE=yes
4) Activate the binding channel
To activate binding, raise all slaves. If the interface has been activated during the modification process, you need to disable the interface first.
So we will first disable the interface
# ifdown ifcfg-ens33 Device 'ens33' successfully disconnected. # ifdown ifcfg-ens34 Device 'ens34' successfully disconnected.
Now we will reactivate the interface
# ifup ifcfg-ens33 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5) # ifup ifcfg-ens34 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
Or reload all interfaces
# nmcli con reload
You can check the configuration with the following command:
# ifconfig bond0: flags=5187
mtu 1500 inet 192.168.43.100 netmask 255.255.255.0 broadcast 192.168.43.255 inet6 fe80::20c:29ff:feb4:f30a prefixlen 64 scopeid 0x20 ether 00:0c:29:b4:f3:0a txqueuelen 1000 (Ethernet) RX packets 26 bytes 4705 (4.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 22 bytes 3711 (3.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens33: flags=6211 mtu 1500 ether 00:0c:29:b4:f3:0a txqueuelen 1000 (Ethernet) RX packets 13 bytes 2196 (2.1 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12 bytes 2072 (2.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens34: flags=6211 mtu 1500 ether 00:0c:29:b4:f3:0a txqueuelen 1000 (Ethernet) RX packets 13 bytes 2509 (2.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10 bytes 1639 (1.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1 (Local Loopback) RX packets 1172 bytes 86468 (84.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1172 bytes 86468 (84.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
You will see that only the bound interface has an IP address. You can also check the configuration with the following command
# cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: ens33 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: ens33 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:b4:f3:0a Slave queue ID: 0 Slave Interface: ens34 MII Status: up Speed: 1000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:0c:29:b4:f3:14 Slave queue ID: 0
For more details on Ethernet bonding, refer to the linuxfoundation page.
Link monitoring can be enabled via the miimon or arp_interval parameter, where miimon monitors the carrier status detected by the underlying network device, and arp monitor (arp_interval) monitors the connection to another host on the local network. If no link monitoring is configured, the bound driver will fail to detect link failures and will assume that all links are always available. When link monitoring is enabled, the failed device is disabled. Active backup mode will fail over to the backup link, other modes will ignore the failed link.
- How to use IP commands in Linux by example
- 14 tcpdump commands to capture network traffic in Linux