Setting network on Debian Squeeze with teaming, bridge and VLANs

Here is a quick procedure to setup your network on your Debian based server, with nic teaming, bridging and allowing VLANs.

  1. Install required packages :
  2. apt-get install ifenslave-2.6 bridge-utils vlan

  3. Activate module :
  4. echo -e 'alias bond0 bonding \noptions bonding mode=4 miimon=100' >> /etc/modprobe.d/aliases.conf

  5. Edit your interfaces file :
  6. vi /etc/network/interfaces

    Here is my configuration :


    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The bond0 (team) network interface
    auto bond0
    iface bond0 inet manual
    slaves eth0 eth1
    post-up ifup br-vlan10 br-vlan90 br-vlan104

    # bond for VLAN 10
    iface bond0.10 inet manual
    vlan-raw-device bond0

    # bond for VLAN 90
    iface bond0.90 inet manual
    vlan-raw-device bond0

    # bond for VLAN 104
    iface bond0.104 inet manual
    vlan-raw-device bond0

    # bridge for VLAN 10
    iface br-vlan1 inet static
    address 10.160.100.15
    netmask 255.255.255.0
    gateway 10.160.100.2
    broadcast 10.160.100.255
    bridge_ports bond0.10

    # bridge for VLAN 90
    iface br-vlan90 inet manual
    bridge_ports bond0.90

    # bridge for VLAN 104
    iface br-vlan104 inet manual
    bridge_ports bond0.104

  7. Restart your computer / server.

If you have to troubleshoot your configuration, you can use following commands :

  • Show bridge details : brctl  show
  • Show VLANs details : cat /proc/net/vlan/config

You will also have to configure VLANs on your switch interfaces, here are the commands to do it on a Cisco switch :

enable
configure terminal
interface Gi0/40
description Server KVM3
switchport trunk encapsulation dot1q
switchport trunk allowed vlan 10,90,104
switchport mode trunk

You are done!