Linux Ethernet Bonding Configuration

Ethernet bonding refers to aggregating multiple ethernet channels together to form a single channel. This is primarily used for redundancy in ethernet paths or for load balancing. This page refers in particular to performing ethernet bonding under linux, and so does not limit itself to discussion of 802.3ad Trunk Aggregation.

Ethernet Bonding Types

The linux kernel bonding module supports a number of bonding types.

Round Robin

Packets are transmitted in a round robin fashion over the available slave interfaces. Provides both load balancing and fault tolerance

Active Backup

One slave interface is active at any time. If one interface fails, another interface takes over the MAC address and becomes the active interface. Provides fault tolerance only. Doesn’t require special switch support

Balance XOR

Tranmissions are balanced across the slave interfaces based on ((source MAC) XOR (dest MAC)) modula slave count. The same slave is selected for each destination MAC. Provides load balancing and fault tolerance.

Broadcast

Transmits everything on all slave interfaces. Provides fault tolerance.

802.3ad

This is classic IEEE 802.3ad Dynamic link aggregation. This requires 802.3ad support in the switch and driver support for retrieving the speed and duplex of each slave.

Balance TLB

Adaptive Transmit Load Balancing. Incoming traffic is received on the active slave only, outgoing traffic is distributed according to the current load on each slave. Doesn’t require special switch support

Balance ALB

Adaptive Load Balancing – provides both transmit load balancing (TLB) and receive load balancing for IPv4 via ARP negotiation. Doesn’t require special switch support, but does require the ability to change the MAC address of a device while it is open

Setup Bonding Ethernet on Debian and ubuntu with a 2.4 kernel

To use Bonding Ethernet for High-Availability (fail-over) on Debian (Woody, Sarge,etch or Sid with a 2.4.x kernel) and ubuntu you need to:

install package ifenslave-2.4.To install this package follow this command

#apt-get install ifenslave-2.4

make sure the real NICs kernel modules are loaded automatically

edit /etc/network/interfaces to look like this:

iface bond0 inet static
address 10.31.1.5
netmask 255.255.255.0
network 10.31.1.0
gateway 10.31.1.254
up /sbin/ifenslave bond0 eth0
up /sbin/ifenslave bond0 eth1

comment or borrow the lines referring to your real NICs in the same file

add the following lines to your /etc/modutils/arch/i386:

alias bond0 bonding

options bonding mode=1 miimon=100 downdelay=200 updelay=200

Now run the following command for update

#update-modules

Setup Bonding Ethernet on Debian and ubuntu with a 2.6 kernel

To use Bonding Ethernet for High-Availability (fail-over) on Debian (Woody, Sarge,etch or Sid with a 2.4.x kernel) and ubuntu you need to:

install package ifenslave-2.6.To install this package follow this command

#apt-get install ifenslave-2.6

make sure the real NICs kernel modules are loaded automatically

edit /etc/network/interfaces to look like this:

iface bond0 inet static
address 10.31.1.5
netmask 255.255.255.0
network 10.31.1.0
gateway 10.31.1.254
up /sbin/ifenslave bond0 eth0
up /sbin/ifenslave bond0 eth1

comment or borrow the lines referring to your real NICs in the same file

add the following lines to your /etc/modprobe.d/arch/i386:

alias bond0 bonding

options bonding mode=1 miimon=100 downdelay=200 updelay=200

Sponsored Link

9 thoughts on “Linux Ethernet Bonding Configuration

  1. This howto is incomplete. What if I have 4 NICs and I want to create two separate bonding devices with two slaves each ?

    As far as I have tried, I manage to get the bond0 interface up but I can not get bond1 up using /etc/network/interfaces.

  2. And I have need for an active failover bond consisting of two load balanced bonds. I fear bonding only supports enslaving of “real” eth interfaces, though. Has anobody tried that?

  3. Can you provide an example of /etc/network/interfaces with two IP addresses on the same bonding interface ?
    Thanks

  4. Hi,
    I have NIC0 (local network), NIC1 (ISP provider 1) and NIC2 (ISP provider 2 – for backup), how do I create backup bonding between NIC1 & NIC2 for gateway. Any help on this will be much appreciated.

  5. ow do I create backup bonding between NIC1 & NIC2 for gateway
    Forget it. In real world you can’t do this. You need to use dynamic routing or floating static routes

  6. There is a bug in Debian Squeeze which cause bonding not to boot up.
    module-init-tools package is buggy, do not upgrade Lenny to Squeeze if You use bonding until this bug is fixed.

    Currently, I’m building a test beowulf cluster in virtual environment just for my college lesson. Squeeze was needed becouse other bug (in kernel-package) caused that I was unable to build my own kernel.

    I used sucessfuly bonding before on:
    Debian Etch – just for load balancing 2 x 100Mbit cards in two machines hosting Samba and service tools
    Debian Lenny – for LAN interface for double speed (2x1Gbps) in a routing server (it’s a gateway for LAN). I have static routes.
    Ausidada: I’m working on same problem. Have to recompile kernel with “dead gateway detection” and routing patches. Next have to create static tables. There is no way to create backup for ISP using bonding. It’s good for connection beteween servers or for LAN.

  7. There is a bug in some 2.6.26 and 2.6.32 kernels with bonding driver. I found it in Xen kernels.

    If you want two bond interfaces the option: modprobe bonding max_bonds=2
    does not work

    Instead of 2 intrerfaces 3 or 4 it works! i.e: modprobe bonding max_bonds=3

    Its an annoying bug.

  8. Regarding the bug in squeeze that tom mentions: i checked with the debian maintainer of the module-init-tools package. he had not heared about that bug, and reports that he himself runs bonded interfaces on squeeze without problems.

Leave a comment

Your email address will not be published. Required fields are marked *