Network Bonding is the combination of multiple LAN interfaces to create a single bond. The main purpose is to improve throughput/redundancy and bandwidth. Network Bonds can be created on different types of devices that include; Physical and virtual Ethernet devices. This protects environments from service loss due to failures on a single link thus increasing fault tolerance.
The advantages related to network bonding are:
- Uninterrupted service in case of failover – incase one service provider connection fails, internet is available from backup connection from other service provider if two connections from different service providers are already available.
- Higher internet speeds – which is almost double than single connection. This inturn offers fast browsing experience to the users.
- Simple to implement and/or deploy.
- Software apps are available for free download.
There are 7 types of Network Bonding:
- mode=0: the default bonding type based on the Round-Robin policy(from the first interface to the last). It provides fault tolerance and load balancing features.
- mode=1: it is based on the Active-Backup policy(only a single interface is active, when it fails, the other one is activated). It cas as well provide fault tolerance.
- mode=2: This mode sets an XOR mode performing an XOR operation of the source MAC address with the destination MAC address.
- mode=3: it is based on the broadcast policy where all packets are transmitted to all the interfaces.
- mode=4: also known as Dynamic Link Aggregation mode. It creates aggregation groups with the same speed.
- mode=5: also known as adaptive transmission load balancing. Here, the current load on each interface determines the distribution of the outgoing packets. The current interface receives the incoming packets, If not, it is replaced by the MAC address of another interface.
- mode=6: also known as adaptive load balancing. The network bonding driver intercepts the ARP replies from the local device and overwrites the source address with a unique address of one of the interfaces in the bond.
This guide aims to provide the required knowledge on how to configure Network Bonding on Ubuntu 22.04|20.04|18.04.
Setup Pre-requisites
For this guide, ensure you have:
- sudo access to your server.
- Two or more interface adapters available.
Step 1: Install the Bonding module on Ubuntu 22.04|20.04|18.04
Before we begin, you need to ensure that the bonding module is installed on your Kernel using the command below.
Load the module.
sudo modprobe bonding
Verify if it is enabled.
$ sudo lsmod | grep bonding
bonding 167936 0
Otherwise, you will be required to install it:
sudo apt install ifenslave
Load the modules in the kernel, so they can be activated automatically on boot.
echo 'bonding' | sudo tee -a /etc/modules
Step 2 – Configure Temporary Bonding
Temporary bonds will be lost after a system reboot. Begin by identifying the available ethernet interfaces on your system.
$ ip a
Sample Output:
Here, we have two interfaces enp9s0 and enp10s0. Ensure the two interfaces are disconnected.
sudo ifconfig enp9s0 down
sudo ifconfig enp10s0 down
Create a network bond with the type 802.3ad as below.
sudo ip link add bond0 type bond mode 802.3ad
Once created, add the two network interfaces to it.
sudo ip link set enp9s0 master bond0
sudo ip link set enp10s0 master bond0
Verify the bond creation using the command:
sudo ip link
Sample Output:
That is it, we have created a temporary bond. Remember this will be lost once the system reboots.
Step 3.1 – Configure Permanent Bonding using Netplan on 22.04|20.04|18.04
To configure a permanent Network Bonding on Ubuntu, edit the Netplan YAML file under /etc/netplan/ as below.
sudo vim /etc/netplan/00-installer-config.yaml
In the file, add the below lines.
network:
version: 2
ethernets:
enp9s0:
dhcp4: no
enp10s0:
dhcp4: no
bonds:
bond0:
interfaces: [enp9s0, enp10s0]
addresses: [192.168.205.100/24]
gateway4: 192.186.205.1
parameters:
mode: active-backup
transmit-hash-policy: layer3+4
mii-monitor-interval: 1
nameservers:
addresses:
– “8.8.8.8”
– “1.1.1.1”
You also use other bond types apart from active-backup(bond=2). Save the file and stop the two interfaces.
sudo ifconfig enp9s0 down
sudo ifconfig enp10s0 down
Restart the network.
sudo netplan apply
Now start the Network bond.
sudo ifconfig bond0 up
Verify if the bond is running.
sudo ifconfig bond0
Sample Output:
You can also view the detailed Network bond status.
sudo cat /proc/net/bonding/bond0
Sample Output:
As seen, we have configured the Bonding mode to active-backup with the two interfaces and enp10s0 currently active.
Step 3.2 – Configure Permanent Bonding on Ubuntu 22.04|20.04|18.04 manually
You can as well configure permanent bonding on Ubuntu by manually editing network-scripts under /etc/network/interfaces
Open the file using your favorite editor.
sudo vim /etc/network/interfaces
In the file, configure Network Bonding by adding the bond interface as below.
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto enp10s0
iface enp10s0 inet dhcp
auto enp9s0
iface enp9s0 inet dhcp
##The Bond Configuration##
auto bond0
iface bond0 inet static
address 192.168.205.150
netmask 255.255.255.0
gateway 192.168.205.1
bond-mode 1
bond-primary enp10s0
bond-slaves enp9s0 enp10s0
bond-miimon 100
bond-downdelay 400
bond-updelay 800
Save the file and activate the bond as below.
sudo ifdown enp9s0 enp10s0
sudo ifup bond0
The bond should be available and this can be verified as below.
sudo cat /proc/net/bonding/bond0
Step 4 – Test the Network Bonding functionality
Since we have configured the active-backup policy where only a single interface is active, when it fails, the other one is activated.
So to demonstrate if it is working, we will deactivate the active interface(enp10s0). Depends on the one active on your system.
sudo ifconfig enp10s0 down
Now check the active slave.
The output verifies that the active-backup policy is working perfectly.
Done!
That marks the end of this guide. You are now equipped with the required knowledge on how to configure Network Bonding on Ubuntu 22.04|20.04|18.04 . I hope this guide was of great value to you.