Wednesday, 22 May 2013

Ubuntu 12.04.2 LTS Interface bonding (802.3ad / LACP) with vlan tagging (802.1q)

Ubuntu 12.04.2 LTS Interface bonding (802.3ad) with vlan tagging (802.1q)

I just had a little wrestle to get this working on 12.04.2 so thought I would write it down quick!

Not sure why but the interface configuration changed between earlier versions of Ubuntu and 12.04.2 LTS.

I followed this guide to get bonding working. My switches support 802.1q / LACP make .  I must admit to already having vlan tagged interface and I cannot remember all of the steps, but my interface config works.

Before you start think about how you are connecting to this server. Are you changing an Interface that you are using to connect to the server? Do you have a backup plan to control it if your config does not work first time?

Install the bonding package. (I am using aptitude, if you use apt-get use that instead ;-)

sudo aptitude install ifenslave

Install the vlan package.

sudo aptitude install vlan

Add the modules bonding and 8021q so they are loaded by the kernel.

nano /etc/modules

# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.


Edit the interface config.

sudo nano -w /etc/network/interfaces

Example config.

# Create a bond0 interface that binds eth1 and eth3 together.
auto eth1
        iface eth1 inet manual
bond-master bond0

auto eth3
        iface eth3 inet manual
bond-master bond0

# Next configure bond0 interface, I had to set an IP, I would prefer to use null..

UPDATE: if you don't want to set an IP address then instead of "iface bond0 inet static" make it "iface bon0 inet manual". Thanks to Sean for the tip.
# NB the bond-mode, try bond-mode 0 if LACP fails.

auto bond0
        iface bond0 inet static
        bond-slaves none
        bond-miimon 100
bond-mode 802.3ad

If you need more bonding modes have a look at this it might help.

# Next create as many vlan tagged Interfaces as you need!

auto bond0.140
        iface bond0.140 inet static
        dns-search w00t.local
vlan-raw-device bond0

auto bond0.10
        iface bond0.10 inet static
vlan-raw-device bond0

auto bond0.180
        iface bond0.180 inet static
vlan-raw-device bond0

Save the changes and reboot your server. You can restart the networking service if you prefer.
Now when you issue the ifconfig command you will see bond0 and bond0.vlanx interface.

Additional useful commands.

Check your bonded interfaces are working as expected, this will also show the LACP actor and partner keys.

cat /proc/net/bonding/bond0

Hope this helps someone.


  1. Thanks, this helped me a lot to setup a bonded/vlan/bridged configuration today. In particular I didn't know about ifenslave, this prevented "operation not allowed on bond0" type of messages.

  2. Cheers for the blog if you dont want to set a IP on the parent bond interface change

    auto bond0
    iface bond0 inet static


    auto bond0
    iface bond0 inet manual

    Then you dont have to IP the parent bond interface

  3. thanks, just what i needed