How to Setup LACP Bonding Interfaces on Ubuntu

Written by: Bagus Facsi Aginsa
Published at: 15 Aug 2021


In ubuntu 18.04 or later, we have an application called netplan to manage our network. The configuration file is located in /etc/netplan directory. In this tutorial, We will be using netplan to setup LACP bonding interfaces on UBuntu.

Prerequisite

  1. Ubuntu 18.04 or Later

Sudo Privileges

Before start we make sure that we will have no permission issue on the installation and configuration process.

sudo su

Use Case

To demonstrate how we can make LACP bonding interfaces, we will use this use case:

                          __________________     
                         |______            |
     --------------------| eth0 |           |
     192.168.1.0/24      |______|  ubuntu   |
     --------------------| eth1 |  server   |
                         |______|           |
                         |__________________|

Let’s assume we have a server with 2 interfaces named eth0 and eth1, connected to switch that is already configured with LACP bonding. The ip address assigned to the server is 192.168.1.10/24 with gateway 192.168.1.1.

Install Dependencies

To make an LACP bonding, we have to install ifenslave first:

apt install ifenslave

Activate the bonding module on server by running this command:

modprobe bonding

To make the module activate on boot, open this file:

nano /etc/modules

add this line:

bonding

Netplan Configuration

To configure the network in our server, first open the configuration file:

nano /etc/netplan/50-cloud-init.yaml

In my server the file name is 50-cloud-init.yaml, maybe it is different in your case. Just open the yaml file located on /etc/netplan directory.

This is how the configuration is implemented to suits the use case we mention above:

network:
    ethernets:
        eth0:
            dhcp4: false
        eth1:
            dhcp4: false
    bonds:
        bond0:
            interfaces: [eth0, eth1]
            addresses: [192.168.1.10/24]
            gateway4: 192.168.1.1
            parameters:
                mode: 802.3ad
    version: 2

We see on the on part interfaces: [eth0, eth1], we will bonding eth0 and eth1 as one interface named bond0. Note that we can add more interface as we need by put in the interface name to the array.

As we see that we use mode: 802.3ad, it is a sign that we use LACP for bonding the interface.

After editing the file, use this command to activate the new configuration:

netplan apply

Thats it! Congratulation you just setup LACP bonding interfaces on Ubuntu 18.04!