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 |
| /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2 |
/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 |
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) Slave Interface: eth1 Slave Interface: eth2 |
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
Interface bonding | iptables and more on Linux | Drakz Free Online Service wrote:
[...] Interface bonding | iptables and more on Linux Share and [...]
Link | January 20th, 2010 at 8:26 am