Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

What Is Network Bonding? Types and Setup

Combine two or more network interfaces into one for more speed or for failover, and set it up on CentOS and Ubuntu.

How-To Guides3 min read1 screenshot
Network bonding

What is network bonding

Network bonding (also called NIC teaming) joins several network interfaces into one logical interface called bond0. Bonding gives you:

  • Redundancy. If one cable or card fails, the other keeps the connection alive.
  • More bandwidth in some modes, because traffic can use several links.
  • Load balancing over the links.

Bonding modes

  • mode=0 (balance-rr). Round-robin. Packets go out through each interface in turn. It gives load balancing and fault tolerance.
  • mode=1 (active-backup). One interface is active, the others wait. If the active one fails, another takes over. It is simple and works with any switch.
  • mode=2 (balance-xor). Chooses the interface by a hash of the MAC addresses. Gives load balancing and fault tolerance.
  • mode=3 (broadcast). Sends every packet on all interfaces. It gives high fault tolerance.
  • mode=4 (802.3ad). Link aggregation (LACP). It needs a switch that supports LACP. It gives both more bandwidth and fault tolerance.
  • mode=5 (balance-tlb). Adaptive transmit load balancing. It does not need special switch support.
  • mode=6 (balance-alb). Adaptive load balancing for transmit and receive. It does not need special switch support.

Configure bonding on CentOS and Red Hat (network-scripts)

Note: Old network-scripts are used up to CentOS 7. On newer systems (CentOS 8 and later, AlmaLinux, Rocky Linux) use NetworkManager, shown below.

Create the bond interface:

vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
TYPE=Bond
BONDING_MASTER=yes
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes
BOOTPROTO=none
BONDING_OPTS="mode=1 miimon=100"

Edit each physical interface (here eth0; do the same for eth1):

vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes

Load the bonding module with the mode (older style):

vi /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bond0 mode=1 miimon=100

miimon=100 checks the link every 100 milliseconds.

Restart the network:

service network restart

Check it:

ip addr show bond0
cat /proc/net/bonding/bond0

Configure bonding with NetworkManager (CentOS 8+, AlmaLinux, Rocky)

nmcli con add type bond con-name bond0 ifname bond0 bond.options "mode=active-backup,miimon=100"
nmcli con add type ethernet slave-type bond con-name bond0-port1 ifname eth0 master bond0
nmcli con add type ethernet slave-type bond con-name bond0-port2 ifname eth1 master bond0
nmcli con mod bond0 ipv4.addresses 192.168.1.10/24 ipv4.gateway 192.168.1.1 ipv4.method manual
nmcli con up bond0

Configure bonding on Ubuntu (Netplan)

network:
  version: 2
  ethernets:
    eth0: {}
    eth1: {}
  bonds:
    bond0:
      interfaces: [eth0, eth1]
      addresses: [192.168.1.10/24]
      routes:
        - to: default
          via: 192.168.1.1
      parameters:
        mode: active-backup
        mil-monitor-interval: 100

Apply it with sudo netplan try and then sudo netplan apply.

Warning: A mistake in network settings can cut your access to a remote server. Keep console access.

Quick recap

  • Mode 1 (active-backup) is the safest choice, mode 4 (LACP) gives the most speed with a supporting switch.
  • Check the state with cat /proc/net/bonding/bond0.