Interface bonding

January 19, 2010

As network cards or links may fail, we may solve this problem by creating multiple links to our network devices. One way is interface bonding which we will configure one in our example.  I assume that your linux have three interfaces eth0,eth1 and eth2. We will use two of the interfaces;

Slave Interfaces : eth1 and eth2
Bonding interface: bond0

1) First add the followings into /etc/modprobe.conf file to provide module paramaters:

alias bond0 bonding
options bond0 mode=active-backup  miimon=100

With this configuration, we use active backup mode. By that, if the primary interface goes down for some reason, bonding system will fail over into the other interface. If you want to use round robin load balancing which will enable to use both interfaces actively use “balanced_rr” instead of “active-backup

2) Configure slave and bonding interfaces.


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

DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:0c:29:47:49:8d
MASTER=bond0
SLAVE=yes

/etc/sysconfig/network-scripts/ifcfg-eth2

DEVICE=eth2
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:0c:29:47:49:97
MASTER=bond0
SLAVE=yes

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

DEVICE=bond0
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.0.0.230
NETMASK=255.255.255.0
BROADCAST=10.0.0.255

3) Now bring up the bonding interface and look at “ip addr” output

#ifup bond0

#ip addr

3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 1500 qdisc pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:47:49:8d brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 qlen 1000
link/ether 00:0c:29:47:49:8d brd ff:ff:ff:ff:ff:ff
inet 10.0.10.129/24 brd 10.0.10.255 scope global eth3
9: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue
link/ether 00:0c:29:47:49:8d brd ff:ff:ff:ff:ff:ff
inet 10.0.0.230/24 brd 10.0.0.255 scope global bond0

You might have noticed that both eth1 and eth2 use the same MAC address which actually what we expect and how it works.

In order to see the bonding status and current active slave interface, issue the following;

[root@rh54]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.4.0 (October 7, 2008)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth2
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: down
Link Failure Count: 1
Permanent HW addr: 00:0c:29:47:49:8d

Slave Interface: eth2
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:0c:29:47:49:97

Here you can see the real mac addresseses of the interfaces.

4) Fail over test

You can actually test how fail over works. In my vmware test system, I have disconnected eth1 and active slave (eth1)  failed over into eth2 at around 3 secs. (I was pinging at the same time) It switches over quite fast but what I have realized is, system keeps the previous mac address even though the interface having that MAC failed. For example in my setup (according to the previous bond0 output), eth1 is failed and eth2 is active slave however other nodes in the network know my 10.0.0.230 IP of having 00:0c:29:47:49:8d MAC. It is quite reasonable indeed. We don’t have to change mac and send unnecessary gratitous arp requests. Once one of your interfaces goes down in your bonding you will see a similar output in your dmesg.

eth1: link down
bonding: bond0: link status definitely down for interface eth1, disabling it
bonding: bond0: making interface eth2 the new active one.

That is all for this article, please drop your comments if you have anything to add or questions.

You can find quite a lot of information about bonding at the following address. I recommend you to read it

http://www.linuxfoundation.org/collaborate/workgroups/networking/bonding

tags:
posted in networking by admin

Follow comments via the RSS Feed | Leave a comment | Trackback URL

1 Comment to "Interface bonding"

  1. Interface bonding | iptables and more on Linux | Drakz Free Online Service wrote:

    [...] Interface bonding | iptables and more on Linux Share and [...]

Leave Your Comment

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org