Nic Bonding

Nic Bonding on CentOS

Nic bonding allows multiple physical interfaces to be bonded together into a single bond interface. This can both increase capacity of the link and add redundancy. It can be configured to balance traffic between the two interfaces via round-robin, active/backup, IEEE 802.3ad for dynamic link aggregation, and so on. There are several more configuration options available, but lets just start with a simple load balanced setup to add redundancy to your links. If a cable goes out for whatever reason, your machine will remain online through the other.

Enable bond0 interface module

Add “alias bond0 bonding” to /etc/modprobe.d.

echo "alias bond0 bonding" >> /etc/modprobe.d/bond0.conf

Create bond0 interface conf file

We’ll create /etc/sysconfig/network-scripts/ifcfg-bond0. I’ll give it the IP 192.168.77.22, netmask 255.255.255.0.

echo "DEVICE=bond0" > /etc/sysconfig/network-scripts/ifcfg-bond0
echo "BOOTPROTO=none" >> /etc/sysconfig/network-scripts/ifcfg-bond0
echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/ifcfg-bond0
echo "NETWORK=192.168.77.0" >> /etc/sysconfig/network-scripts/ifcfg-bond0
echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-bond0
echo "IPADDR=192.168.77.22" >> /etc/sysconfig/network-scripts/ifcfg-bond0
echo "USERCTL=no" >> /etc/sysconfig/network-scripts/ifcfg-bond0

Add interface eth0 and eth1 to bond0

Now we’ll create confs for the two physical connections to bond0.

# eth0
echo "DEVICE=eth0" > /etc/sysconfig/network-scripts/ifcfg-eth0
echo "BOOTPROTO=none" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "MASTER=bond0" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "SLAVE=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth0
echo "USERCTL=no" >> /etc/sysconfig/network-scripts/ifcfg-eth0
 
# eth1
echo "DEVICE=eth1" > /etc/sysconfig/network-scripts/ifcfg-eth1
echo "BOOTPROTO=none" >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo "MASTER=bond0" >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo "SLAVE=yes" >> /etc/sysconfig/network-scripts/ifcfg-eth1
echo "USERCTL=no" >> /etc/sysconfig/network-scripts/ifcfg-eth1

Bring up bond0 interface

ifup bond0
(Comments)

Comments