Network Channel Bonding for Failover in Red Hat Linux

Channel bonding in Linux enables two or more physical network interfaces to act as a single interface on a system. There are several bonding modes available which can simultaneously provide increased bandwidth and/or redundancy. For this entry, we will be looking at a simple fault-tolerant configuration. A load-balanced configuration will be covered in a later entry.

As mentioned above, there are 6 channel bonding modes. The mode we want to look at right now is mode 1, or active-backup. Here, we will bond eth0 and eth1 to a single mode 1 channel. In this mode, all
transmissions are received and sent out via the first available bonded slave interface. The other bonded slave interface is only used if the active bonded slave interface fails.

1. Create a network script file for the bond device. We’ll call the device bond0.

[root@santa ~]# cd /etc/sysconfig/network-scripts/
[root@santa network-scripts]# vi ifcfg-bond0
DEVICE="bond0"
BOOTPROTO="static"
GATEWAY="192.168.2.1"
IPADDR="192.168.2.5"
NETMASK="255.255.255.0"
NM_CONTROLLED="yes"
ONBOOT="yes"
BONDING_OPTS="miimon=1000 mode=active-backup"

There are a number of parameters that can be assigned to the BONDING_OPTS variable. However, in this case, we are only concerned with the mode (active-backup) and the miimon which specifies (in milliseconds) how often MII link monitoring occurs. This is useful if high availability is required because MII is used to verify that the NIC is active.

2. Modify the network configuration files for each of the interfaces assigned to the channel bond.

[root@santa network-scripts]# vi ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no

[root@santa network-scripts]# vi ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no

3. We also need to ensure that the kernel module is loaded when the bonding interface is enabled. To do this, we populate a file called /etc/modprobe.d/.conf with the following line:

alias bondN bonding

This file can have any name you like as long as it is appended with the .conf suffix. Note that you must replace N with the interface number, such as 0. So in our case, the contents of the file will be:

[root@santa network-scripts]# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding

Note that for each configured channel bonding interface, there must be a corresponding entry in the
/etc/modprobe.d/.conf file. So, if we had multiple bonds, the config file would have multiple lines.

4. Now, we will restart the networking service. It is best to do this from the console in order to diagnose and repair any potential problems with the network configuration.

[root@santa network-scripts]# service network restart
[root@santa network-scripts]# ifconfig -a
bond0 Link encap:Ethernet HWaddr 78:AC:C0:FC:F1:64
inet addr:192.168.2.5 Bcast:192.168.2.255 Mask:255.255.255.0
inet6 addr: fe80::7aac:c0ff:fefc:f164/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:20462 errors:0 dropped:3878 overruns:0 frame:0
TX packets:883 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2217821 (2.1 MiB) TX bytes:103195 (100.7 KiB)

eth0 Link encap:Ethernet HWaddr 78:AC:C0:FC:F1:64
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:12678 errors:0 dropped:3878 overruns:0 frame:0
TX packets:883 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1376813 (1.3 MiB) TX bytes:103195 (100.7 KiB)

eth1 Link encap:Ethernet HWaddr 78:AC:C0:FC:F1:64
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:7784 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:841008 (821.2 KiB) TX bytes:0 (0.0 b)

Now, we’ll test the failover.

[root@santa network-scripts]# ifconfig eth0 down

We see in the syslog that the bond has failed over to eth1.

Nov 30 13:03:00 santa kernel: bonding: bond0: link status definitely down for interface eth0, disabling it
Nov 30 13:03:00 santa kernel: bonding: bond0: making interface eth1 the new active one.

Now we bring back eth0.

[root@santa network-scripts]# ifconfig eth0 up

From syslog, we can see that the bond has failed back to the primary interface.

Nov 30 13:03:17 santa kernel: eth0: Link up
Nov 30 13:03:17 santa kernel: bonding: bond0: link status definitely up for interface eth0.

About these ads

2 Responses to Network Channel Bonding for Failover in Red Hat Linux

  1. Pingback: Network Channel Bonding for Load Balancing in Red Hat Linux « mieklefield

  2. Pingback: LinuxTarget » Blog Archive » Network Channel Bonding for Load Balancing in Red Hat Linux

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: