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
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 18.104.22.168 dns-search domain.local slaves eth0 eth1 bond_mode 0 bond-miimon 100 bond_downdelay 200 bond_updelay 200
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
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
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
Next use mii-tool tool to check Network Interface Controller (NIC) parameters as shown.
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.
6 thoughts on “How to Configure Network Bonding or Teaming in Ubuntu”
There is a typo in the interfaces config example:
Thanks, corrected the variable in the configuration…
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?
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?
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: wlp4s0: IAID conflicts with one assigned to enp3s0
Jun 05 11:30:45 fallback-os dhcpcd: wlp4s0: adding address fe80::3e65:1ccc:341a:27c9
Jun 05 11:30:45 fallback-os dhcpcd: wlp4s0: soliciting a DHCP lease
Jun 05 11:30:46 fallback-os dhcpcd: wlp4s0: offered 192.168.1.178 from 192.168.1.254
Jun 05 11:30:46 fallback-os dhcpcd: wlp4s0: soliciting an IPv6 router
Jun 05 11:30:46 fallback-os dhcpcd: wlp4s0: probing address 192.168.1.178/24
Jun 05 11:30:46 fallback-os dhcpcd: 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.
ISP1, both have different gateways and IP addresses.
So based on what have you put those static values for bond0?