How to Setup Network Bonding in Ubuntu 20.04

The practice of merging different network interfaces into one is known as network bonding or pairing. The main goal of network binding is to enhance performance and capacity while also ensuring network redundancy. Furthermore, network bonding is advantageous where fault allowances are a crucial consideration, such as in load balancing connections. Packages for network bonding are available in the Linux system. Let's have a look at how to set up a network connection in Ubuntu using the console. Before you start, make sure you have the following items:

  • An administrative or master user account
  • There are two or more interface adapters available.

Install the bonding module in Ubuntu

We need to install the bonding module first. Hence log in from your system and open the command-line shell quickly by “Ctrl+Alt+T”. Make sure to have the bonding module configured and enabled in your Linux system. To load the bonding module type the below command followed by the user password.

$ sudo modprobe bonding

Install bonding kernel module

The bonding has been enabled as per the below query:

$ lsmod | grep bond

Check if bonding module is loaded in Linux Kernel

If your system has missed the bonding, make sure to install the ifenslave package in your system via the apt package followed by adding the password.

$ sudo apt install ifenslave

Install ifenslave

Affirm your installation action process by hitting “y” from the typewriter. Otherwise, press “n” to quit the installation.

Proceed with installation

You can see the system has successfully installed and enabled network bonding on your system as per the below last lines of output.

ifenslave installed

Temporary Network Bonding

Temporary bonding is only lasting until the next reboot. This means when you reboot or restart your system it fades away. Let’s begin the temporary bonding. First of all, we need to check how many interfaces are available in our system to be bonded. For this purpose, write out the below command in the shell to check it out. Add your account password to proceed. The output below shows that we have two Ethernet interfaces enp0s3 and enp0s8 available in the system.

$ sudo ifconfig

ifconfig

First of all, you need to change the state of both the Ethernet interfaces to “down” using the following commands:

$ sudo ifconfig enp0s3 down
$ sudo ifconfig enp0s8 down

shutdown network

Now, you have to make a bond network on master node bond0 via the ip link command as below. Make sure to use bond mode as “82.3ad”.

$ sudo ip link add bond0 type bond mode 802.3ad

bond network on master node bond0 via the ip link command

After the bond network bond creation, add both the interfaces to the master node as below.

$ sudo ip link set enp0s3 master bond0
$ sudo ip link set enp0s8 master bond0

bond0

You can affirm the creation of network bonding using the below query.

$ sudo ip link

Check network bond

Permanent Network Bonding

If somebody wants to make a permanent networking bonding, they have to make changes to the configuration file of network interfaces. Hence, open the file in GNU nano editor as below.

$ sudo nano /etc/network/interfaces

Edit /etc/network/interfaces file

Now update the file with the below following configuration. Make sure to add bond_mode as 4 or 0. Save the file and quit it.

Network bonding configuration

To enable the network bond, we need to change the states of both slaves interfaces to down and change the state of the master node to up, using the below query.

$ sudo ifconfig enp0s3 down && sudo ifconfig enp0s8 down & sudo ifconfig bond0 up

activate network config

Now restart the network service using the below systemctl command.

$ sudo systemctl restart networking.service

Restart networking

You can also use the below command instead of the above command.

$ sudo systemctl restart network-manager.service

Restart network manager

Now you can confirm whether the master interface has been “up” or not using the below query:

$ sudo ifconfig bond0

Show bond0 config

You can check out the status of a newly created network bond that has been created successfully by utilizing the below query.

$ sudo cat /proc/net/bonding/bond0

Show network bonding from proc/net/ virtual filesystem

Conclusion

This article explains how to combine several network interfaces into a single platform using the Linux bridging package. Hope you got no issues while implementation.