This tutorial is setting up a network bonding with two network interfaces in a server with the help of a managed network swtich (LACP-Link Aggregation Control Protocol, 802.3ad)

In linux system, there are several modes in the network bonding. (Ref: Link)

  • 0: balance-rr
  • 1: active-backup
  • 2: balance-xor
  • 3: broadcast
  • 4: 802.3ad
  • 5: balance-tlb
  • 6: balance-alb

Only the 802.3ad mode requires LACP support in the switch side.

As we have a managed switch, Pica8 P-3297, I have configured a network bonding with 802.3ad mode.

Pica8 P-3297 Setup

  1. Change the switch mode to L2/L3.

Pica8 P-3297 can support OVS (OpenVSwitch for SDN) mode as well as the ordinary L2/L3 switch mode. First things to do is changing the mode to L2/L3 mode. You can change the mode with the command picos_boot.

The L2/L3 mode is the number 2 in the options.

admin@XorPlus# picos_boot
Please configure the default system start-up options:
(Press other key if no change)
[1] PicOS L2/L3
[2] PicOS Open vSwitch/OpenFlow
[3] No start-up options * default
Enter your choice (1,2,3):
  1. Configure

Pica8 P-3297 has 48x 1Gbps ports (ge-1/1/1 - ge-1/1/48) and 4x 10Gbps SFP+ ports (te-1/1/49 - te/1/1/52). I will bundle two 1Gbps ports into one aggregated network interface. For the name of the aggregated network interface, Pica8 P-3297 is using ae (ae1 - ae52).

Here’s an example configuration to bundle ge-1/1/1 and ge-1/1/2 to ae1. It enables LACP and makes the aggregated interface activated when there are two active ports.

admin@XorPlus$ cli
admin@XorPlus> configure
admin@XorPlus# set interface aggregate-ethernet ae1
admin@XorPuls# set interface aggregate-ethernet ae1 aggregated-ether-options lacp enable true
admin@XorPlus# set interface aggregate-ethernet ae1 aggregated-ether-options min-selected-port 2
admin@XorPlus# set interface gigabit-ethernet ge-1/1/1 ether-options 802.3ad ae1
admin@XorPlus# set interface gigabit-ethernet ge-1/1/2 ether-options 802.3ad ae1
admin@XorPlus# commit
admin@XorPlus# exit
admin@XorPlus> exit
admin@XorPlus$

If there are aggregated ports, hashing policy determins which port should be used to send data. You can use simple metrics like source mac address, destination mac address, source IP address, destination IP address, or source + destination IP addresses.

set interface aggregate-ethernet aeX hash-mapping mode <mode>

You also have more complex combination of metrics. In this case, you have to select the hash-mapping mode to `advance’ and select which metrics you will include or exclude. The possible metrics are ethernet-source, ethernet-destination, ethernet-type, ip-source, ip-destination, ip-protocol, port-source, port-destination, vlan-id, and ingress-interface.

set interface aggregate-ethernet aeX hash-mapping mode advance
set interface aggregate-balancing hash-mapping field <field-name> disable <true|false>

Here’s an example I configured in the swtich to use layer3+4. It is noted that all the fields are inclusive by default, you should disable the field to exclude from using it.

admin@XorPlus$ cli
admin@XorPlus> configure
admin@XorPlus# set interface aggregate-ethernet ae1 hash-mapping mode advance
admin@XorPuls# set interface aggregate-balancing hash-mapping field ethernet-source-address disable true
admin@XorPuls# set interface aggregate-balancing hash-mapping field ethernet-destination-address disable true
admin@XorPuls# set interface aggregate-balancing hash-mapping field ethernet-type disable true
admin@XorPuls# set interface aggregate-balancing hash-mapping field ingress-interface disable true
admin@XorPuls# set interface aggregate-balancing hash-mapping field vlan disable true
admin@XorPlus# commit
admin@XorPlus# exit
admin@XorPlus> exit
admin@XorPlus$

Host (Server) Setup

I am using netplan to configure network.

Here’s an template for a netplan config (located at /etc/netplan/01-bonding.yaml). It uses eno1 and eno2 as underlying ports. The macaddress is optional. If you are configuring the bonding from scratch you can omit the macaddress. But if you are changing from the existing networking setup, you have to put the MAC address that is currently using for the Internet access. Otherwise, your machine cannot get the IP address from the DHCP server.

network:
  version: 2
  renderer: networkd
  ethernets:
    bond0ports:
      match:
        name: eno[12]
      optional: true
  bonds:
    bond0:
      interfaces: [bond0ports]
      macaddress: xx:xx:xx:xx:xx:xx
      dhcp4: yes
      dhcp6: yes
      parameters:
        mode: 802.3ad
        lacp-rate: fast
        mii-monitor-interval: 100
        transmit-hash-policy: layer3+4