Saturday, May 7, 2011

Debian Link Aggregation (Network Bonding)

Here we are going setup link aggregation for Debian. Your system must have at least 2 network interfaces (but not limited to).

Bonding

  1. Install ifenslave-2.6 package:
    apt-get install ifenslave-2.6
    
  2. Load bonding kernel module:
    modprobe bonding
    
  3. Note that you shouldn't have any configuration for eth0 and eth1, they are attached as slaves for bond0 interface. Network configuration (file /etc/network/interfaces):
    auto bond0
    iface bond0 inet static
         address 192.168.10.14
         netmask 255.255.255.0
         network 192.168.10.0
         broadcast 192.168.10.255
         gateway 192.168.10.1
    
         slaves eth0 eth1
    
         # Transmit packets in sequential order 
         # from the first available slave through 
         # the last. This mode provides load 
         # balancing and fault tolerance.
         bond-mode balance-rr
    
         # Only one slave in the bond is active. 
         # A different slave becomes active if, 
         # and only if, the active slave fails. 
         #This mode provides fault tolerance.
         #bond-mode active-backup
    
         bond-miimon 100
         bond-downdelay 200
         bond-updelay 200
    
  4. Once above is complete you need to reboot your server so the network changes take place (that should be faster than bringing up/down network interfaces and restarting networking service).

Bridge

You can use link aggregation with network bridge, for example if you are using lxc / kvm virtualization. Here is network configuration (file /etc/network/interfaces):
auto bond0
iface bond0 inet manual
     slaves eth0 eth1
     bond-mode balance-rr
     bond-miimon 100
     bond-downdelay 200
     bond-updelay 200

auto br0
iface br0 inet static
     address 192.168.10.14
     netmask 255.255.255.0
     network 192.168.10.0
     broadcast 192.168.10.255
     gateway 192.168.10.1
     bridge_ports bond0
     bridge_fd 0
     bridge_maxwait 0
     bridge_stp off

Network Switch

If your switch supports port trunking you should add the switch ports used by eth0 and eth1 to a single trunk.

3 comments :

  1. Hello :)
    First of all ....thanks for this tutorial! Really useful!

    However from my last experience in configuring bonding I noted I had to to a couple of extra configurations:

    1) manually load module mii by inserting it in /etc/modules

    2) manually set miimon parameter for module bonding by creating the fine /etc/modprobe.d/bonding and adding the following line to it:

    options bonding miimon=100

    Have you done these two configuration step?

    ReplyDelete
  2. The above was setup for debian testing (kernels 2.6.39 and 3.0.0).

    1) The only module loaded per this post is bonding. There was no need for mii module to load. I have checked if it has been loaded via some sort of dependency I missed - no, it is not in the list of loaded modules.

    2) miimon option (see bond-miimon 100) is set in network interface configuration. There were no need to configure the module directly since network interface options gives me such ability.

    ReplyDelete
  3. Hello :)

    I'm using Debian Stable 6.0.2 with linux 2.6.32 and the server is equipped with the Ethernet cards Intel Corporation 80003ES2LAN Gigabit Ethernet Controller.

    I suppose Stable and Testing have some difference in bond management, in stable I had to perform the two additional configuration steps and mii link monitoring only works with option bonding miimon=100

    Thanks again for the post :)

    ReplyDelete