How to Configure Network Bonding or Teaming in Ubuntu

Network Interface Bonding is a mechanism used in Linux servers which consists of binding more physical network interfaces in order to provide more bandwidth than a single interface can provide or provide link redundancy in case of a cable failure. This type of link redundancy has multiple names in Linux, such as Bonding, Teaming or Link Aggregation Groups (LAG).

Read Also: How to Setup Network Bonding or Teaming in RHEL/CentOS

To use network bonding mechanism in Ubuntu or Debian based Linux systems, first you need to install the bonding kernel module and test if the bonding driver is loaded via modprobe command.

$ sudo modprobe bonding
Check Network Bonding in Ubuntu
Check Network Bonding in Ubuntu

On older releases of Debian or Ubuntu you should install ifenslave package by issuing the below command.

$ sudo apt-get install ifenslave

To create a bond interface composed of the first two physical NCs in your system, issue the below command. However this method of creating bond interface is ephemeral and does not survive system reboot.

$ sudo ip link add bond0 type bond mode 802.3ad
$ sudo ip link set eth0 master bond0
$ sudo ip link set eth1 master bond0

To create a permanent bond interface in mode 0 type, use the method to manually edit interfaces configuration file, as shown in the below excerpt.

$ sudo nano /etc/network/interfaces
# The primary network interface
auto bond0
iface bond0 inet static
	address 192.168.1.150
	netmask 255.255.255.0	
	gateway 192.168.1.1
	dns-nameservers 192.168.1.1 8.8.8.8
	dns-search domain.local
		slaves eth0 eth1
		bond_mode 0
		bond-miimon 100
		bond_downdelay 200
		bond_updelay 200
Configure Bonding in Ubuntu
Configure Bonding in Ubuntu

In order to activate the bond interface, either restart network service, bring down the physical interface and rise the bond interface or reboot the machine in order for the kernel to pick-up the new bond interface.

$ sudo systemctl restart networking.service
or
$ sudo ifdown eth0 && ifdown eth1 && ifup bond0

The bond interface settings can be inspected by issuing the below commands.

$ ifconfig 
or 
$ ip a
Verify Bond Interface in Ubuntu
Verify Bond Interface in Ubuntu

Details about the bond interface can be obtained by displaying the content of the below kernel file using cat command as shown.

$ cat /proc/net/bonding/bond0
Check Bonding Information in Ubuntu
Check Bonding Information in Ubuntu

To investigate other bond interface messages or to debug the state of the bond physical NICS, issue the below commands.

$ tail -f /var/log/messages
Check Bond Interface Messages
Check Bond Interface Messages

Next use mii-tool tool to check Network Interface Controller (NIC) parameters as shown.

$ mii-tool
Check Bond Interface Link
Check Bond Interface Link

The types of Network Bonding are listed below.

  • mode=0 (balance-rr)
  • mode=1 (active-backup)
  • mode=2 (balance-xor)
  • mode=3 (broadcast)
  • mode=4 (802.3ad)
  • mode=5 (balance-tlb)
  • mode=6 (balance-alb)

The full documentations regarding NIC bonding can be found at Linux kernel doc pages.

Matei Cezar
I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

6 thoughts on “How to Configure Network Bonding or Teaming in Ubuntu”

  1. Thank you for your post! Where can I find information about adding network redundancy, not just link redundancy?. Specifically, connecting a single server with 2 NIC’s to 2 separate switches. I’m more worried about a switch failure in the network; it’s the weak link that would shut the whole system down completely. Ideally, I’d have a redundant network allowing (at bare minimum) out-of-band access to remote servers through Telnet, SSH, or web GUI’s.

    Link Aggregation also requires configuration on a switch… meaning a minimum of a QUAD port NIC. If I have only 2 ports, I’m splitting them between switches, not bonding them. So it seems that link aggregation (to me) is a conversation only after network redundancy/stability is achieved. Can you recommend any specific articles or resources?

    Reply
  2. Now that Unbuntu in 20.04 is using Netplan what do I need to do to configure a real server (HPE dl60 H9) with two network interfaces at 192.168.3.24 and 192.168.3.25 as fixed IP with no DHCP and binded into a single interface? Can I still use these commands or do I have to figure out the arcane syntax of Netplan?

    Reply
  3. I’m trying to bond enp3s0 and wlp4s0 interfaces connected to one wireless repeater.

    enp3s0 is connected to ap2, which is connected to ap1.

    wlp4s0 is directly connected to ap1.

    So they are getting IP from one source.

    As enp3s0 first gets ip it’s working fine, but wlp4s0 doesn’t get IP because of error:

    wlp4s0: IAID conflicts with one assigned to enp3s0

    CTRL-EVENT-DISCONNECTED bssid=bc:ee:7b:90:74:c8 reason=4 locally_generated=1

    wlp4s0: IAID 03:d7:8c:63
    Jun 05 11:30:45 fallback-os dhcpcd[23163]: wlp4s0: IAID conflicts with one assigned to enp3s0
    Jun 05 11:30:45 fallback-os dhcpcd[23163]: wlp4s0: adding address fe80::3e65:1ccc:341a:27c9
    Jun 05 11:30:45 fallback-os dhcpcd[23163]: wlp4s0: soliciting a DHCP lease
    Jun 05 11:30:46 fallback-os dhcpcd[23163]: wlp4s0: offered 192.168.1.178 from 192.168.1.254
    Jun 05 11:30:46 fallback-os dhcpcd[23163]: wlp4s0: soliciting an IPv6 router
    Jun 05 11:30:46 fallback-os dhcpcd[23163]: wlp4s0: probing address 192.168.1.178/24
    Jun 05 11:30:46 fallback-os dhcpcd[23163]: wlp4s0: hardware address f8:1a:67:5c:7c:e2 claims 192.168.1.172

    It would be great if someone could help to resolve this issue.

    Reply
  4. I have eth0 from ISP0 and eth1 from ISP1, both have different gateways and IP addresses.

    So based on what have you put those static values for bond0?

    "address 192.168.1.150
    netmask 255.255.255.0	
    gateway 192.168.1.1"
    
    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.