I always thought that its not very complicated. But in fact, to have it working I had to spend some time.
Bonding let us combine many ethernet devices into one or more groups, with right switch configuration it can duble bandwitch on bond0 interface so it can be quite usefull for example on our gateway. Let add vlan support for all of this.
First of all we need to
apt-get install ifenslave (on older systems you can find ifenslave-2.4 nad ifenslave-2.6)
Now lets create configuration for our first bond0 interface.
... auto bond0 iface bond0 inet manual bond-miimon 100 lacp_rate slow slaves eth0 eth1 ...
Then we need to be sure, that our bonding will load after a reboot. Lets create a file in /etc/modprobe.d/ and lets call it bonding
alias bond0 bonding options bonding mode=1 miimon=100 downdelay=200 updelay=200
Now if we dont want to have vlans, we can set the ip for the interface finish the job. Bue we want vland ontop of bond0.
Creating vlans on bond0
Like with bond, we need to
apt-get install vlan to be able to work with vlans. (its in the debian standard repo)
Again we need to edit /etc/network/interfaces
auto vlan4 auto vlan5 auto vlan101 # VLAN 4 iface vlan4 inet static address 192.168.10.8 netmask 255.255.255.192 network 192.168.10.0 broadcast 192.168.10.63 mtu 1500 vlan_raw_device bond0 # VLAN 5 iface vlan5 inet static address 10.0.111.8 netmask 255.255.255.0 network 10.0.111.0 broadcast 10.0.111.255 mtu 1500 vlan_raw_device bond0 # VLAN 101 iface vlan101 inet static address 18.104.22.168 netmask 255.255.255.0 network 22.214.171.124 broadcast 126.96.36.199 gateway 188.8.131.52 mtu 1500 vlan_raw_device bond0
Like you can see, vlan_raw_device is pointing the bond0 raw interface. Now its time to create our vlans in the system.
rumplebump:~# vconfig add bond0 194
During the creation, you can have an error like this:
---dmesg --- Jul 9 12:14:45 rumplebump kernel: register_vlan_device: VLANs not supported on bond0.
To solve this, you should edit bond0 configuration in /etc/network/interfaces
auto bond0 iface bond0 inet manual bond-mode 802.3ad <---- add this! bond-miimon 100 xmit_hash_policy layer2+3 <--- add this! lacp_rate slow slaves eth0 eth1
Now all we need is reboot (you can create vlnas with vconfig and reload the networking but do a reboot if you can)
After that, you should have a working bond0 interfave with vlans on top.
rumplebump:~# cat /proc/net/vlan/config VLAN Dev name | VLAN ID Name-Type: VLAN_NAME_TYPE_PLUS_VID_NO_PAD vlan4 | 4 | bond0 vlan5 | 6 | bond0 vlan101 | 101 | bond0