Skip to content

Interface Bonding

Network interface bonding is a critical technique for enhancing redundancy and load balancing in Linux systems. By aggregating multiple physical interfaces into a single logical bond, administrators can achieve fault tolerance, increased bandwidth, and optimized traffic distribution. This section covers configuring bonding modes like active-backup (for redundancy) and balance-alb (for load balancing), along with practical examples and best practices.


Prerequisites and Kernel Support

Before configuring bonding, ensure:
- Physical interfaces are connected and functional.
- The bonding kernel module is loaded (modprobe bonding).
- The bonding driver is supported by your kernel (check /boot/config-$(uname -r) for CONFIG_BONDING).


Configuring Bonding Modes

1. Active-Backup Mode

Use Case: Redundancy with a single active interface and a backup.
Steps:
1. Create the bond interface:

sudo ip link add bond0 type bond mode active-backup
2. Add slaves (e.g., eth0 and eth1):
sudo ip link set eth0 master bond0
sudo ip link set eth1 master bond0
3. Set the primary interface (optional):
sudo ip link set bond0 primary eth0
4. Bring the bond online:
sudo ip link set bond0 up
5. Assign an IP address:
sudo ip addr add 192.168.1.100/24 dev bond0
sudo ip route add default via 192.168.1.1 dev bond0

Note: Failover occurs automatically if the primary interface fails.


2. Balance-ALB Mode

Use Case: Load balancing with ARP-based traffic distribution.
Steps:
1. Create the bond interface:

sudo ip link add bond0 type bond mode balance-alb
2. Add slaves:
sudo ip link set eth0 master bond0
sudo ip link set eth1 master bond0
3. Bring the bond online:
sudo ip link set bond0 up
4. Assign an IP address (same as above).

Key Behavior:
- Traffic is distributed based on ARP tables.
- Requires the balance-alb mode to be supported by the bonding driver.


Persistent Configuration with systemd-networkd

To ensure bonding survives reboots, configure it in /etc/systemd/network/ (e.g., bond0.network):

[Match]
Name=bond0

[Network]
BondMode=balance-alb
BondSlaves=eth0 eth1
Address=192.168.1.100/24
Gateway=192.168.1.1
Routes=8.8.8.8
Enable and start the service:
sudo systemctl enable systemd-networkd
sudo systemctl start systemd-networkd


Troubleshooting and Monitoring

  • Check bond status:
    ip -s link show bond0
    
  • Verify ARP tables:
    arp -a
    
  • Check kernel logs:
    dmesg | grep bonding
    
  • Common issues:
  • Missing bonding module.
  • Incorrect mode configuration (e.g., balance-alb requires specific kernel support).
  • Misconfigured ARP settings for load balancing.

Key takeaways

  • Bonding modes like active-backup (redundancy) and balance-alb (load balancing) address different use cases.
  • Persistent configuration via systemd-networkd or nmcli ensures reliability across reboots.
  • Monitoring tools like ip and dmesg help diagnose bonding issues.
  • Always verify kernel support and ARP settings for advanced modes.
  • Use modprobe to load the bonding module if it’s not already active.