How to Setup Network Bonding in Ubuntu

ubuntu

Wondering how to setup network bonding in Ubuntu?

Network bonding refers to the process which allows the user to combine multiple network interfaces into a single network interface. This allows us to obtain a network interface with enhanced throughput, redundancy, and increased bandwidth which can be tweaked according to our needs.

There’s no doubt that network bonding is a useful tool if you’re working in the networking industry. This is because the bandwidth provided by a bonded network exceeds that provided by a single network interface. 

Network bonding provides your interface with a failsafe. It protects the network from data loss (e.g., data loss due to faults in cables) and allows for optimal balancing of loads.

Seeing all these advantages, we can conclude that setting up network bonding is worth the trouble, which is why you’re here. If you stumbled across this article wondering how to set up network bonding in Ubuntu, you came to the right place!

With the help of this guide, you’ll be combining interfaces via network bonding in no time. 

So without further waiting, let’s begin!

Modes of Network Bonding.

Knowing about the different modes of network bonding operation can prove useful, as these modes accomplish the same task, i.e., transferring data but utilize different means or policies for the execution. These modes are explained below.

Mode_0 – This mode is set as default and gets the job done in most cases. It accomplishes the task through Round-robin scheduling i.e.; information is transferred in the form of packets in a cyclic manner(starts from the first and ends at the last interface of the bonded network.)

Mode_1 – This network bonding mode uses the Active Backup policy, i.e., only one interface is running at a time. A different interface will activate if and only if the first one fails. This mode is not preferred if you’re looking for load balancing.

Mode_2 – This mode utilizes the XOR policy, i.e., it performs the XOR operation between the base(source) and the MAC addresses (destinations).

Mode_3 – This mode implements the Broadcast policy, i.e., packets are transmitted to all bond network interfaces. It is used in specific cases for providing fault tolerance.

Mode_4 – This mode refers to IEEE 802.3ad. It aggregates interfaces into groups with equal speeds. Transmit hashing determines the interface for throughput.

Mode_5 – This mode uses Adaptive Transmission Load Balancing, i.e., distribution of outgoing packets is determined by the current load on each interface. If the currently active interface doesn’t get any packets, another interface’s MAC address will act as the new receptor of the packets.

Mode_6 – This mode uses the balance-tlb and Receive Load Balancing (rlb), which utilizes ARP negotiation. This method is used for dealing with IPV4 traffic. Switch support is not available with this mode.

Now that you have a basic understanding of all modes, you are ready to learn how to set up network bonding in Ubuntu.

Step 1: Checking and Installing the Bonding Module.

The first step is to verify whether the bonding module is installed in your Linux distribution. If the bonding module is not installed, we can install it with the help of the terminal. Knowing whether the bonding module is installed on the system will save you from the process of trying to install the bonding module. 

In other words, you will save yourself from a redundant process. With the help of the Command-Line Input(CLI), we can check for the module using the $ lsmod command. 

It should be noted that you can only set up network bonding if you are a sudo or root user. Nevertheless, it’s a given that you will need multiple network interfaces for this to work. 

To ensure that the module is installed on your Linux distribution, follow these steps.

  1. First, open the terminal by pressing Ctrl + Alt + T.
  2. Next, type in the following command
$ sudo lsmod | grep bonding

If the module is not installed, then type in the following command.

$ sudo apt-get install ifenslave
  1. Now, Load the module by typing the following command in your terminal.
$ sudo modprobe bonding

This will successfully load the bonding module on your Linux distribution.

If you followed the steps correctly, you should have configured and installed the bonding module on your system. The next step is to create a bond interface.`

Step 2: Setting Up a Bond Interface.

Now that you have installed the bonding module on your Linux distribution, you are ready to set up a bond interface.

There are two methods to set up a bond interface. Although both methods accomplish the same task, i.e., creating a bond interface, the difference lies in the duration of the newly created network interface. One creates a temporary (ephemeral) network bond, while the other is a more permanent solution.

Follow these steps to enable temporary bonding.

  1. Firstly, open the terminal by pressing Ctrl + Alt + T.
  2. Next, type in the following command
$ sudo ipconfig

In some cases, ipconfig doesn’t work. If that happens, then try the following

$ sudo ip a

This will show you all the available interfaces.

Network Bonding in Ubuntu
  1. Now, a network bond can be created by typing the following command. Use the names of the network interfaces you wish to bond together.
$ sudo ifconfig lo down
$ sudo ifconfig enp0s3 down
$ sudo ip link add bond0 type bond mode 802.3ad
  1. Lastly, combine both interfaces by typing the following commands.
$ sudo ip link set lo master bond0
$ sudo ip link set enp0s3 master bond0

If you followed the steps correctly, then congratulations! You have now created a bond interface. Remember that the bond interface will cease to exist after you restart your system. 

If you’re looking to create a permanent bond interface, follow these steps.

  1. Open the terminal and type the following command.
$sudo nano /etc/network/interfaces

You can replace nano with any text editor such as gedit.

  1. In the newly opened file, append the following text in the script.
auto bond0
iface bond inet static
address 192.168.0.253
netmask 255.255.255.0
gateway 192.168.0.1
dns-search domain-name.local
slaves lo enp0s3
bond_mode 4
bond-miimon 100
bond-downdelay 0
bond-updelay 0
GNU Nano
  1. Once that’s finished, type the following command.
$ sudo ifconfig lo down && sudo ifconfig enp0s3 down & sudo ifconfig bond0 up
$ sudo service restart network-manager

This will enable your newly created bond interface.

  1. Make sure that the interface is running by typing the following command.
$ sudo ipconfig bond0

Or if that doesn’t work, type the following

$ sudo ip a

With the steps followed correctly, you have now created a permanent bond interface. If you wish to see how your network bond operates, type the following command in the terminal.

$ sudo cat proc/net/bonding/bond0

We hope our guide helped you learn how to set up network bonding in Ubuntu and wish you a pleasant experience on your journey to master networking.

Furthermore, if you wish to learn how to connect to the WiFi from the terminal in Linux, click here.

If this guide helped you, please share it. 🙂

Leave a Reply

Your email address will not be published.

Previous Post

CE-33986-9 Error on PS4 or PS5? Here’s the Fix!

Next Post

How to Run Java from Command Line in Linux

Related Posts