• Contact: +91 (0) 6296384546

Centos 6 Bonding

Back

Bonding NICs can help us achieve high network availability even if one of the network card falls down. Usually, bonding NICs are implement for high-speed no interruption service like SAN storage.

First off all, make sure your server has 2 or more NICs to be combined. Make sure all of them are connected to a same switch.

Variables that We used:

OS: CentOS 6 64bit
Storage server main IP: 192.168.0.100
Network interface cards involved: eth0, eth1, eth2, eth3

 

1. Make sure we have the utilities to bond NICs. Run following command to install:

yum install ethtool -y


2. Create a new bond NIC called bond0. This will be our bonding master interface, where our real NIC will be use as slave interface. Whenever a slave NIC down, another slave NIC will take over so the master interface will be not affected:

touch /etc/sysconfig/network-scripts/ifcfg-bond0
vi /etc/sysconfig/network-scripts/ifcfg-bond0


And add following line:

DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
USERCTL=no
BOOTPROTO=no


3. Now we need to change some values on every physical NICs configuration files that we have. In this case, I will need to change following files under /etc/sysconfig/network-scripts directory:

ifcfg-eth0:

DEVICE=eth0
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
BOOTPROTO=no


ifcfg-eth1:

DEVICE=eth1
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
BOOTPROTO=no


ifcfg-eth2:

DEVICE=eth2
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
BOOTPROTO=no


ifcfg-eth3:

DEVICE=eth3
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
BOOTPROTO=no


4. Now we need to register the bonding module inside CentOS as a device. We need to create a new files called bonding.conf under /etc/modprobe.d directory:

touch /etc/modprobe.d/bonding.conf
vi /etc/modprobe.d/bonding.conf


Add following line: [ Mode = 4 for LACP, Mode = 5 for Balance-rr ]

alias bond0 bonding
options bond0 miimon=100 mode=4 lacp_rate=1 xmit_hash_policy=layer3+4

5. Add the module to kernel:

modprobe bonding


6. Restart network:

service network restart


Done! You will noticed that another interface is added into interface list (ifconfig) called bond0. You can monitor the bonding state by running following command:

watch -n1 'cat /proc/net/bonding/bond0'