http://liorkaplan.wordpress.com/2009/01/03/network-bonding-types-and-configurationin-linux/Network bonding types and configuration in LinuxBy Lior KaplanA few days after the first time I created a network bonding device in Linux, I had to create two network bonding on the same machine. Sounds simple, but it seems that be default you can create only one device. As I tried to figure how to create two devices, I had a chance to investigate a bit on the issue of network bonding. While the setting in /etc/sysconfig/network-scripts are quite simple and straight forward (see the RHEL References guide - Channel Bonding Interfaces), the settings in /etc/modules.conf hold some options to choose from. First, we need to have a line the says that the device is a bonding
device, so the the bonding module will manage it: Most how-to also sugget to add the following line: But the mode parameter has a meaning that the system administrator should choose:
Other, more advanced modes are documented in the Kernel documentation at Documentation/networking/bonding.txt and the RHEL References guide - bonding Module Directives. Returning to my original issue - creating two network boding
devices. By default the bonding module let you create only one bonding
device, adding the line Notice that this time the options are for the bond module and not for a specific alias of the module. RHEL5, lets you change the bonding options in the bond config file
(e.g. /etc/sysconfig/network-scripts/ifcfg-bondo), with the
BONDING_OPTS variable: On RHEL4, you can achive the same goal with these settings in /etc/modules.conf:
as it causes the bonding module to be loaded twice and alias each one of the differently. On RHEL machines you’ll need the iputils packages, which has /sbin/ifenslave to add the slaves to the bond when the are configured. One Response to “Network bonding types and configuration in Linux” |
04/01/2009 at 5:37 am
The bonding driver will automatically create “max_bonds” (default 1) bonding devices on module load, however this is not really a maximum limit of any kind.
You can easily dynamically create more bonding virtual interfaces via the sysfs API. I believe ifenslave is deprecated.
eg. to create bond1 - bond10 in balance-rr mode with two slaves each
for N in {1..10}; do
BOND=”bond$N”
SLAVE1=”eth$(( $N * 2 ))”
SLAVE2=”eth$(( $N * 2 + 1 ))”
echo “+$BOND” >/sys/class/net/bonding_masters
echo balance-rr >/sys/class/net/$BOND/bonding/mode
echo 100 >/sys/class/net/$BOND/bonding/miimon
ip link set $BOND up
echo “+$SLAVE1″ >/sys/class/net/$BOND/bonding/slaves
echo “+$SLAVE2″ >/sys/class/net/$BOND/bonding/slaves
done
On debian you could (I do) use a similar script as pre-up commands for the bond interface.