User Tools

Site Tools


Bonding on Debian

It is useful to manage load balancing and failover to have an high availablity network.

Installation of ifenslave-2.6

First we need to install ifenslave-2.6:

apt-get install ifenslave-2.6

Bonding module configuration

Then add a bonding module configuration file into /etc/modprobe.d/

cd /etc/modprobe.d/
touch aliases-bond

and configure the module by editing (VI) the /etc/modprobe.d/aliases-bond file and adding these two lines:

alias bond0 bonding
  options bond0 mode=0 miimon=200

Bonding name

Where bond0 is the bonding aggreggation name. You could imagine to configure more aggregats to match your specific needs with several network interfaces.

Bonding mode

I personaly tested each modes (0-6) and the mode 0 was choosed because it matches my needs:

  • mode=0 (balance-rr) Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.

and others discarded (e.g mode 6) because the failover mode failed during testing or the load-balancing was not evident. For more informations on “mode” you can have a look at

Bonding failover check

The mii-tool method

The configuration above uses this method by setting miimon=200.

(The next part was originaly explained by )

Using 'mii-tool' you should see something like the following:

testbox:/# mii-tool
eth0: negotiated 100baseTx-FD, link ok
eth1: negotiated 100baseTx-FD, link ok

In order for this to work, the kernel must have support for bonding devices. A few ways to check would be:

testbox:/# modprobe --list | grep bonding/lib/modules/
testbox:/# cat /boot/config- | grep -i bonding

We use the mii-tool (mii.o module) to monitor the interfaces for failover… though, as most ethernet adapters use an MII (Media Independant Interface) to autonegotiate link speeds, its pretty standard that you'd have this.

testbox:/# cat /boot/config- | grep -i mii# CONFIG_MPENTIUMII is not set
testbox:/# modprobe --list | grep -i mii

FIXME : what about the two options:


The ARP method

For this method you have to garanty either a reliable host/firewall/router… because it will ping it in order to define if the interface is up or not! This is not the best choice! First if you ping a firewall and the “echo” protocols is not allowed, then your network cards will be turned of and this is also the case if you ping a host that is turned off or his network card is down!!!!

To use this method, you have to replace the “miimon” option by the arp options. This will produce a module configuration like:

alias bond0 bonding
  options bond0 mode=0 arp_interval=2000 arp_ip_target=

In this example, each network interface will ping the ip each 2 seconds.

Interfaces configuration

Then, you have to reconfigure your /etc/network/interfaces file.

DHCP configuration

The first example uses a DHCP server to get the IP address and so uses the pre-up ifconfig command line.

auto bond0
iface bond0 inet dhcp
        pre-up modprobe bond0
        pre-up ifconfig bond0 up;/sbin/ifenslave bond0 eth0 eth1
        hwaddress ether 00:14:5E:D8:xx:xx
        down ifenslave -d bond0 eth0 eth1

pre-up commands

The two pre-up commands ask respectively to add the module/device and its configuration into the kernel and the second allows the DHCP requests to be done before the aggregation is set up.

hwaddress configuration

This can be either one or the other real mac address of you network card or something completely invented. Be aware that you should not found two times the same mac address on your network.

STATIC configuration

auto bond0
iface bond0 inet static
        pre-up modprobe bond0
        hwaddress ether 00:14:5E:D8:xx:xx
        up ifenslave bond0 eth0 eth1
        down ifenslave -d bond0 eth0 eth1

on Debian, you can replace the two last lines (up/down) with:

        slaves eth0 eth1

Looking at the bonding configuration

You can check the actual configuration of your bonding module by cat-ting the device configuration file:

cat /proc/net/bonding/bond0

Reconfiguration of the bonding module

If you do some modifications on the bonding module configuration file (/etc/modprobe.d/aliases-bond), you need first to remove the bonding module:

modprobe -r bond0

By restarting your network devices either with

/etc/init.d/networking restart


ifup -a

it will automatically add again the module because it is asked to do so in the /etc/network/interfaces file with the command “pre-up modprobe bond0”.

Shuttdown the aggregation

This works as for another interface:

ifconfig bond0 down

Failover Tests

You can test the failover by detaching (-d) a “dead” interface:

ifenslave -d bond0 eth0

which will warn you as:

bonding: bond0: releasing active interface eth0

and your connection is still active through the eth1 interface.

You can of course reconnect the interface:

ifenslave bond0 eth0


operating_systems/linux/debian/bonding_on_debian.txt · Last modified: 2011/08/15 05:35 by sbolay