Linux Bonding on CentOS 5.x

Linux Bonding on CentOS 5.x



Recently i have been working with bonding interfaces in Linux(CentOS 5). I have done a lot of testing with different configurations and thought I would share how I set them up. Its a basic configuration, but gets the job done.

Create the Bond Interface

Define an alias so that the kernel module is loaded before the bonding interface is brought up
edit
/etc/modprobe.conf

add
alias bond0 bonding
etc…

Create the config file for the bond
edit
/etc/sysconfig/network-scripts/ifcfg-bond0

sample config

DEVICE=bond0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
BONDING_OPTS="mode=1 miimon=80 primary=eth0 primary=eth0 primary_select=always"
IPADDR=10.0.0.1
NETMASK=255.0.0.0

Now lets break it down.

DEVICE – Is the name of the physical device
ONBOOT – Says the interface will be activated at boot
BOOTPROTO – Specifies no boot-time protocol
USERCTL – Specifies that non root users are not allowed to control the device
IPADDR – This is your IPv4 address
NETMASK – This is your subnet mask
BONDING_OPTS – This is where you specify the parameters for the bond.

There are several modes that I have been playing with. Active-backup and Adaptive load balancing

Modes:

LB Mode Friendly Value Numeric Value
Round Robin balance-rr 0
Active Backup active-backup 1
XOR Policy balance-xor 2
Broadcast broadcast 3
802.3ad Link Aggregation 802.3ad 4
Adaptive Transmit balance-tlb 5
Adaptive Load Balancing balance-alb 6

miimon – This specifies the monitoring frequency(ms) to detect link failures

primary – This specifies which interface is the primary. This means that once the link failre occurs it will will fail back to the primary interface once restored

primary_reselect – This specifies what to do when the failure is restored. In my example, I want it to fail back to eth0 once restored.

Configure the Slave Interfaces

For each of the interfaces you want to participate in the bond you will need to configure it to be a slave.

Sample:

DEVICE=eth0
#HWADDR=xx:xx:xx:xx:xx:xx
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes

Verify the Configuration

Once you have confgiured the the bond and slave interfaces, you will need to restart the network service.

service network restart

During the service restart you can often see error message. I have found them to be benign.

To confirm the bond setting and status of both the bond and slave.

cat /proc/net/bonding/bond0

This will show a similar output.

Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: eth0 (primary_reselect always)
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 80
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: xx:xx:xx:xx:xx:xx

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: xx:xx:xx:xx:xx:xx



Categories