Load balancing network bonding device from multiple physical interfaces

My new mobo has two gigE ports, so I figure why not trunk them together to work as one network device? This will work great for a Linux based network storage device (NAS).

This will create a virtual interface named bond0 with the external ip address of 192.168.1.100. Anything else on my network will see this computer with this address. It doesn’t matter which interface is actually plugged in, one, the other, or both. As long as one is plugged in it will continue to function.

To test it out without making any persistent configuration changes:

# /sbin/modprobe bonding
# /sbin/ifconfig bond0 192.168.1.100
# /sbin/ifenslave bond0 eth0
# /sbin/ifenslave bond0 eth1

You can run the channel bonding in different modes, but by default I found mine went into a load balanced round-robin.

switchports-upclose

# cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.1.3 (June 13, 2007)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 08:00:32:c7:c5:b1

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 08:00:32:c7:b5:b2

And now the permanent configuration:

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

# Bonding interface
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
IPADDR=192.168.1.100
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
GATEWAY=192.168.1.1

/etc/sysconfig/network-scripts/ifcfg-eth0

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=08:00:32:C7:C5:B1
USERCTL=no
MASTER=bond0
SLAVE=yes

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

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=08:00:32:C7:C5:B2
USERCTL=no
MASTER=bond0
SLAVE=yes

If you have more than two, you can add them in the same way. The only thing different about the two configurations above (eth0 and eth1) is the hardware address and device name.

Restart the network

# /etc/init.d/network restart

Your bond0 interface should have the ipaddress and be UP BROADCAST RUNNING MASTER MULTICAST, while eth0, eth1, …, ethN should all appear as UP BROADCAST RUNNING SLAVE MULTICAST. Now test it out by unplugging one of your physical interfaces while you have a connection to 192.168.1.100. I tried it from a remote host with an ssh session.

Bonding, trunking, link aggregation (hmm maybe that’s slightly different, but whatever)… there’s a host of names for this technology, choose your favorite.

Posted by admica   @   28 October 2009

Related Posts

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

Name

Email

Website

Previous Post
« Load virtual tape drives directly
Next Post
Measure bandwidth between two computers with iperf »
Powered by Wordpress   |   Lunated designed by ZenVerse