
Bonding two Ethernet devices
In this recipe, you'll learn how to combine multiple Ethernet devices as a single network device in a configuration known as channel bonding. Channel bonding allows us to bind multiple devices together so that they appear as a single interface to servers running on the CentOS system. Its purpose is to improve your system's overall network performance and provide redundancy if one of the network devices fails.
Getting ready
This recipe requires a CentOS system with at least two Ethernet devices. It assumes that your primary Ethernet device is enp0s3
. If your device is named differently, substitute the name appropriately in the recipe's commands. You'll also need administrative privileges provided by logging in with the root
account.
How to do it...
Follow these steps to bond two Ethernet devices:
- Install the
bind-utils
andethtool
packages:yum install bind-utils ethtool
- Create a new configuration file for the bonded interface:
vi /etc/sysconfig/network-scripts/ifcfg-bond0
- Add the following lines to the file, substituting values for
IPADDR
,NETMASK
, andBROADCAST
that are appropriate for your network:BOOTPROTO="none" DEVICE="bond0" USERCTL="no" ONBOOT="yes" IPADDR="192.168.56.100" NETMASK="255.255.255.0" BROADCAST="192.168.56.255"
- Save your changes and close the configuration file.
- Open the configuration file of the first device you wish to bond:
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
- Make sure
BOOTPROTO
is set tonone
andONBOOT
is set toyes
. Then remove theIPADDR
,NETMASK
, andBROADCAST
entries if they exist. - Add the
SLAVE
andMASTER
entries at the end of the file:SLAVE=yes MASTER=bond0
- Save your changes and close the configuration file.
- Repeat steps 5-8 for each additional device you want to bond.
- Create the configuration file used by the kernel to control how the bonding interface should behave:
vi /etc/modprobe.d/bonding.conf
- Add the following lines to the file:
alias bond0 bonding options bond0 mode=5 miimon=100
- Save your changes and close the file.
- Register the bonding module with the system's kernel:
modprobe bonding
- Restart networking services for the changes to take effect:
systemctl restart network.service
How it works...
We began by creating a configuration file for the bonding interface at /etc/sysconfig/ network-scripts/ifcfg-bond0
. BOOTPROTO
was set to none
because the IP address is set statically, DEVICE
gives a name to the interface, USERCTL
was set to no
to prohibit nonadministrative users from bringing the interface up and down, and ONBOOT
was set to yes
so that the interface will be automatically activated. We also gave the IP address information with IPADDR
, NETMASK
, and BROADCAST
:
BOOTPROTO="none" DEVICE="bond0" USERCTL="no" ONBOOT="yes" IPADDR="192.168.56.100" NETMASK="255.255.255.0" BROADCAST="192.168.56.255"
Then we updated the configuration files for each device we want to bond. We made sure BOOTPROTO
was set to none
and there was no address information since the device will no longer need its own IP address. Adding the SLAVE
and MASTER
entries, we identified the device as being bound to the new bond0
device:
SLAVE=yes MASTER=bond0
By performing these steps, we have created a new virtual device known as the bonding master that will use our real Ethernet devices as slaves. If one slave device fails, the other slave will still be active, providing redundancy.
Next, we created a new configuration file with our preferences for the kernel bonding module. The module is the kernel implementation of the bonding device and is responsible for coordinating the physical devices:
alias bond0 bonding options bond0 miimon=100 mode=5
miimon=100
specifies that MII link monitoring will occur every 100
milliseconds to verify that the physical devices are active. mode=5
represents a basic configuration that doesn't require any specific type of network switch support. It allows outgoing traffic to be distributed according to the current load on each slave device. There are five other modes which give you plenty of options in configuring how the devices work together, although you should be aware that some modes may require specific hardware support. Refer to http://wiki.centos.org/TipsAndTricks/BondingInterfaces for more information.
After making changes to the device's configuration files, we registered the bonding kernel module using modprobe
:
modprobe bonding

Two Ethernet devices are bound with the same IP addresses through the bonding adapter
See also
For more information on bonding Ethernet devices CentOS, refer to the Configure Network Bonding chapter in the RHEL 7 Networking Guide (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/ch-Configure_Network_Bonding.html).