Network bonding types and configuration in Linux

A 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: alias bondX bonding

Most how-to also sugget to add the following line: options bond0 mode=0 miimon=100 or options bond0 mode=1 miimon=100

But the mode parameter has a meaning that the system administrator should choose:

  • Mode 0 or balance-rr is the Round-robin policy which gives fault tolerance and load balancing. This mode sends are receives package on each node in a sequential order. So the load is distributed on all NICs.
  • Mode 1 or active-backup which gives only fault tolerance without load balancing. This modes sends all packets through the one active slave. The slave changes only if the active slave fails.

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 options bonding max_bonds=2 to /etc/modules.conf lets you (after reloading the driver) to make two bonding devices.

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: BONDING_OPTS="mode=1 miimon=100".

On RHEL4, you can achive the same goal with these settings in /etc/modules.conf:

alias bond0 bonding
options bond0 -o bond0 mode=1 miimon=100
alias bond1 bonding
options bond1 -o bond1 mode=0 miimon=50

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.


Filed under Red Hat Enterprise Linux, System Administration

2 responses to “Network bonding types and configuration in Linux

  1. Edward Allcutt

    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
    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

    On debian you could (I do) use a similar script as pre-up commands for the bond interface.

  2. DJ Saltarelli

    I’m afraid this is wrong for RHEL4 and two bond interfaces. You must use the install command in modprobe.conf

    install bond0 /sbin/modprobe bonding -o bond0 miimon=100 mode=1
    install bond1 /sbin/modprobe bonding -o bond1 miimon=100 mode=0

    or you will only have one module loaded called bonding and bond1 will get the options of bond0. This way, you get two modules bond0 and bond1 and they can have different options.



Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s