Tuesday, December 1, 2015

Linux Network Interface Card Bonding

7:24 PM Posted by Dilli Raj Maharjan , No comments

Channel Bonding helps two or more NIC card act as single. It increase the bandwidth and provides redundancy. In case on one physical NIC is down network traffic moves to another NIC card providing High Availability. We use bond driver to achieve it.

The following instructions are tested on:
OS: CentOS 6.7 installed on Virtual box Version 5.0.10 r104061
VM adapter settings: Bridged Adapter, Paravirtualized Network (virtio-net)
2 Ethernet Adapters eth0, eth1

Create bonding.conf file inside directory /etc/modprobe.d and add following linesalias bond0 bonding








Add following lines on the file bond0 interface configuration file /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
IPADDR=192.168.1.254
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
BONDING_OPTS="miimon=100 mode=1 fail_over_mac=1"
ONBOOT=yes
NM_CONTROLLED=no













Add following lines on file eth0 and eth1 configuration files
/etc/sysconfig/network-scripts/ifcfg-eth0

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











/etc/sysconfig/network-scripts/ifcfg-eth1

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











Now restart network service

/etc/init.d/network restart









Verify failover

Ping IP 192.168.1.254 from another host.

ping 192.168.1.254


Keep watching the /var/log/message log file for interface down.


tail -f /var/log/message

Plug OFF cable from eth0. Message on the log file will be displayed as below
Dec  1 07:53:45 svn NetworkManager[1581]: <info> (eth0): carrier now OFF (device state 1)
Dec  1 07:53:45 svn kernel: bonding: bond0: link status definitely down for interface eth0, disabling it
Dec  1 07:53:45 svn kernel: bonding: bond0: making interface eth1 the new active one.

Plug ON cable on eth0
Dec  1 07:53:55 svn NetworkManager[1581]: <info> (eth0): carrier now ON (device state 1)
Dec  1 07:53:56 svn kernel: bonding: bond0: link status definitely up for interface eth0, 4294967295 Mbps full duplex.

Plug OFF cable on eth1
Dec  1 07:54:00 svn NetworkManager[1581]: <info> (eth1): carrier now OFF (device state 1)
Dec  1 07:54:00 svn kernel: bonding: bond0: link status definitely down for interface eth1, disabling it
Dec  1 07:54:00 svn kernel: bonding: bond0: making interface eth0 the new active one.

Plug ON cable on eth1
Dec  1 07:54:04 svn NetworkManager[1581]: <info> (eth1): carrier now ON (device state 1)
Dec  1 07:54:04 svn kernel: bonding: bond0: link status definitely up for interface eth1, 4294967295 Mbps full duplex.
[root@svn ~]# 


During cable Plug on and OFF, We can notice there is 0% Packet loss output from Ping result

--- 192.168.1.254 ping statistics ---
26 packets transmitted, 26 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.377/0.496/1.085/0.188 ms

0 comments:

Post a Comment