How to set up LACP bonding on Ubuntu 18.04 with Netplan

Estimated reading time: 1 min

Introduction

In this article, we’ll look at how to set up LACP bonding on a server running Ubuntu. LACP bonding uses the Link Aggregation Control Protocol to combine two network interfaces into one logical interface. Today, we’ll use it to combine two ethernet interfaces. This is useful to increase the throughput from each ethernet device and to provide for a way to failover if there’s an error with one of the devices.

Prerequisites

  • The network switch your server is connected to must be set up accordingly in for a successful procedure
  • You need to have the SSH login details of your server ready

Step 1 – Login using SSH

You must be logged in via SSH as sudo or root user. Please see this article for instructions if you don’t know how to connect.

Step 2 – Install the ifenslave dependency

sudo apt-get install ifenslave

Step 3: Load bonding kernel module

Before you can configure the network cards you need to ensure that the kernel module called bonding is present and loaded.

sudo lsmod | grep bonding

If the module is not loaded. Use the following command to load it

sudo modprobe bonding

To ensure that the bonding module is loaded during boot time change file the following file

sudo nano /etc/modules

Add the following line

bonding

Step 4 – find the active network interface

clear && echo $(ip -o -4 route get 8.8.8.8 | sed -nr 's/.*dev ([^\ ]+).*/\1/p')

Step 5 – Configure the network interface

The output of step 4 is the network interface which is active at the moment. You should use that name for the bond. In our case this is enp2s0 and the second interface enp3s0.

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
  version: 2
  ethernets:
    eports:
      match:
        name: enp*
      optional: true
  bonds:
    bond0:
      interfaces: [eports]
      addresses: [78.41.207.45/24]
      gateway4: 78.41.207.1
      nameservers:
        addresses: [89.207.128.252, 89.207.130.252]
      parameters:
        mode: 802.3ad
        lacp-rate: fast
        mii-monitor-interval: 100

Apply the changes

sudo netplan apply

Step 6 – Reboot

reboot

Step 7 – Check bonding interface status

If everything went well, you should have a working bonding interface. You can check this by executing the following command

cat /proc/net/bonding/bond0

Conclusion

Congratulations, you have configured LACP network interface according to IEEE 802.3ad on a Ubuntu server 18.04 with Netplan. If you are interested in other modes which are available check this URL section “Descriptions of bonding modes”.

Was this article helpful?
Dislike 0
Views: 125

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *