CentOS 6: Bonding Multiple Network Interface Cards (NICs)

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. Do not think that bonding will multiply the data transmit. To multiply data transmit, we need to do multipathing. You can refer here for more information: http://blog.open-e.com/bonding-versus-mpio-explained/.

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 as picture below:

Variables that I 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
NETWORK=192.168.0.0
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:

alias bond0 bonding
options bond0 mode=5 miimon=100

List of bonding modes can be refer here:

http://unixfoo.blogspot.com/2008/02/network-bonding-part-ii-modes-of.html

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'

2 thoughts on “CentOS 6: Bonding Multiple Network Interface Cards (NICs)

  1. THERE IS NO GATEWAY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Reply

    1. Hi,

      You can add another entry to specify the gateway for that interface, as example below:
      GATEWAY=192.168.0.1

      Usually, the gateway in CentOS is configured under /etc/sysconfig/network file.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *