How to Create and Configure Network Bonding in Linux Using ip link

Network bonding—also commonly termed Link Aggregation (LAG), NIC teaming, or port trunking—combines multiple physical network interface cards into a single virtual network interface. In enterprise server environments, bonding delivers two critical operational advantages: high availability through automatic link failover, and increased throughput through link aggregation. While network managers like Netplan and NetworkManager frequently manage high-level profiles, configuring network bonds directly through ip link gives system administrators complete, low-level control over kernel bonding parameters without third-party daemon dependencies.

Understanding Linux Bonding Modes

The Linux kernel bonding driver supports seven distinct operational modes, each tailored to specific physical switch architectures and fault-tolerance requirements:

  • Mode 0 (balance-rr): Round-robin transmission across all active subordinate interfaces. Provides load balancing and fault tolerance, but packets may arrive out of order, which can affect TCP performance without specialised switches.
  • Mode 1 (active-backup): Only one subordinate interface remains active at any given moment. If the active link fails, a backup interface immediately takes over without interrupting network connections. This mode requires zero configuration on the upstream physical switch.
  • Mode 2 (balance-xor): Transmits packets based on a hash of the source and destination MAC addresses. Provides load balancing and fault tolerance without requiring switch support.
  • Mode 3 (broadcast): Transmits all traffic across all slave interfaces simultaneously. Primarily used for high-redundancy, mission-critical systems.
  • Mode 4 (802.3ad / LACP): Dynamic link aggregation adhering to the IEEE 802.3ad standard. Aggregates link speeds and provides automatic failover, requiring a managed switch supporting LACP.
  • Mode 5 (balance-tlb): Adaptive transmit load balancing based on interface queue loading. Incoming traffic arrives on the current active slave.
  • Mode 6 (balance-alb): Adaptive load balancing incorporating both transmit and receive load balancing for IPv4 traffic through ARP negotiation.

Prerequisites and Kernel Module Verification

Ensure the Linux kernel bonding module is loaded before creating virtual bond devices. Run:

sudo modprobe bonding

Verify that the bonding module is active by inspecting kernel loaded modules:

lsmod | grep bonding

Step 1: Create the Virtual Bond Device Using ip link

To create a new virtual bond interface (named bond0) operating in active-backup mode with MII link monitoring every 100 milliseconds:

  1. Open your terminal and execute:
    sudo ip link add bond0 type bond mode active-backup miimon 100
  2. If you prefer LACP aggregation (Mode 4), specify mode 802.3ad:
    sudo ip link add bond0 type bond mode 802.3ad miimon 100 lacp_rate fast
  3. Confirm the virtual device creation:
    ip link show bond0
    The kernel displays the new bond0 interface with standard down flags.

Step 2: Attach Subordinate (Slave) Physical Interfaces

Before attaching physical network interfaces (such as eth1 and eth2) to the bond master, ensure they are brought down to release existing IP configurations.

  1. Bring down the physical interfaces:
    sudo ip link set dev eth1 down
    sudo ip link set dev eth2 down
  2. Flush any pre-existing IP addresses assigned to the physical adapters to prevent routing conflicts:
    sudo ip addr flush dev eth1
    sudo ip addr flush dev eth2
  3. Enslave each physical interface to the bond0 master:
    sudo ip link set dev eth1 master bond0
    sudo ip link set dev eth2 master bond0

Step 3: Activate the Bond and Subordinate Interfaces

Once enslaved, bring up the physical subordinate interfaces followed by the bond master:

  1. Bring up the physical adapters:
    sudo ip link set dev eth1 up
    sudo ip link set dev eth2 up
  2. Bring up the virtual master bond device:
    sudo ip link set dev bond0 up

Step 4: Assign IP Addressing and Default Gateway

In a bonded setup, IP addresses and subnet masks must be assigned exclusively to the master bond0 interface, never to the individual physical slave interfaces.

  1. Assign a static IP address and CIDR prefix:
    sudo ip addr add 192.168.1.50/24 dev bond0
  2. Add your default gateway routing rule:
    sudo ip route add default via 192.168.1.1 dev bond0
  3. Alternatively, if your local network operates a DHCP server, invoke your distribution’s DHCP client on the bond:
    sudo dhclient bond0

Step 5: Inspect and Verify Bonding Status

The Linux kernel exposes comprehensive bonding statistics and active link status through the /proc virtual filesystem.

Query the live status using cat:

cat /proc/net/bonding/bond0

The output presents detailed operational diagnostics:

Ethernet Channel Bonding Driver: v5.15.0

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1a:2b:3c:4d:5e

Slave Interface: eth2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:1a:2b:3c:4d:5f

To test failover, physically disconnect the cable from eth1 (or run sudo ip link set dev eth1 down) and inspect /proc/net/bonding/bond0. You will observe that the Currently Active Slave automatically shifts to eth2 within 100 ms without dropping active TCP connections.

How to Tear Down a Bond Device

To release subordinate adapters and remove the virtual bond:

  1. Bring down the bond master:
    sudo ip link set dev bond0 down
  2. Release physical interfaces from the master:
    sudo ip link set dev eth1 nomaster
    sudo ip link set dev eth2 nomaster
  3. Delete the virtual bond device:
    sudo ip link delete bond0 type bond

For more advanced networking guides, explore how to create and configure network bridges in Linux using ip link, create and configure VLAN interfaces in Linux using ip link, learn how to enable and disable promiscuous mode in Linux using ip link for packet analysis, or see how to change network interface MTU in Linux using ip link to optimise jumbo frame transmission across bonded uplinks.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.