Quick Tip: Bonding, LACP, and VLANs in Linux

I have been doing a lot of tinkering with linux based storage (more to come on that!) over the past few weeks and I had to hunt and peck around the internet to find all of the information on using bonding/lacp and vlans in linux so I want to bring it all to one place. All of these configuration files are from Ubnutu but the format should be similar in other distros. All of the switch configurations were on a Cisco 2960 running IOS 12.2-lanbase which is a fairly old and basic switch.

Linux Setup

There are two modules to install for this setup, bonding and 8021q. As follows:

Linux Setup

#install packages
# NOTE: ensure ifenslave 2.6 is what gets installed, required for VLANs
root@filer:~# apt-get install -y ifenslave vlan

#load modules manually to be sure
root@filer:~# modprobe 8021q
root@filer:~# modprobe bonding

#add to modules for reboots
root@filer:~# echo 'bonding' >> /etc/modules
root@filer:~# echo '8021q' >> /etc/modules

Basic Bonding using LACP

Linux

This is the linux side of this link, the important part here is the bond-mode needs to be set to 802.3ad or mode 4.

Eth Config

#slave interfaces
auto eth4
iface eth4 inet manual
bond-master bond0

auto eth5
iface eth5 inet manual
bond-master bond0

#bond interface
auto bond0
iface bond0 inet static
        address 192.168.1.10
        netmask 255.255.255.0
        #there are several modes, this is also known as mode 4
        bond-mode 802.3ad
        bond-miimon 100
        bond-slaves eth4 eth5

Cisco 2960

This is the configuration of the two switch ports and the port channel on the Cisco switch. The important part here is using ‘active’ mode on the channel group.

Port Channels

!vlan 10 is my storage VLAN
interface Port-channel1
 switchport access vlan 10
end

interface GigabitEthernet0/43
 switchport access vlan 10
 channel-group 1 mode active
end

interface GigabitEthernet0/44
 switchport access vlan 10
 channel-group 1 mode active
end

Bonding with VLAN Trunking

Most people need to use both VLANs and 802.3ad trunking in the real world, especially for storage, as it turns out that is pretty easy. In this example I only have one VLAN but the setup can be repeated for each additional VLAN. Also on the “base” interface I don’t have any configuration, this is where the “native” IP configuration would go.

Note: This configuration can also be applied to a non-bonded interface.

Linux

This is the linux side of this link, the important part here is the bond-mode needs to be set to 802.3ad or mode 4.

Eth Config

#slave interfaces
auto eth4
iface eth4 inet manual
bond-master bond0

auto eth5
iface eth5 inet manual
bond-master bond0

#bond interface
auto bond0
iface bond0 inet static
        #native vlan, need ip to configure
        address 1.1.1.1
        netmask 255.255.255.0
        bond-mode 802.3ad
        bond-miimon 100
        bond-slaves eth4 eth5

auto vlan10
iface vlan10 inet static
        address 192.168.1.10
        netmask 255.255.255.0
        broadcast 192.168.1.255
        vlan-raw-device bond0

Cisco 2960

This is also similar to the other configuration, the ‘switchport trunk allowed’ section is optional, I wanted to prune the VLANs for this link.

Port Channels

!vlan 10 is my storage VLAN
interface Port-channel1
 switchport trunk allowed vlan 10
 switchport mode trunk
end

interface GigabitEthernet0/43
 switchport trunk allowed vlan 10
 switchport mode trunk
 channel-group 1 mode active
end

interface GigabitEthernet0/44
  switchport trunk allowed vlan 10
  switchport mode trunk
 channel-group 1 mode active
end

This is a pretty simple setup, post a comment with suggestions or requests for more information and I will keep this post up to date.

References

Comments
comments powered by Disqus

BeyondVM

BeyondVM is a personal blog is about virtualization, system administration archetecture and the business of IT. I post research that I do into better management of virtualization and infrastructure, as well as things that I learn along the way.

Connect
Search
Disclaimer
The views expressed anywhere on this site are strictly mine and not the position of any employer, vendor or provider including but not limited to my employer, VMware or any of its companies. Any solutions that I offer are 'use at your own risk.'
Twitter Follow Me!
Recient Comments