How to Configure a Bond Interface in Ubuntu
Bonding network interfaces is a common practice for improving network performance and reliability. In Ubuntu, you can combine two or more network interfaces into a single logical bonded interface. This is especially useful for redundancy and load balancing.
This guide explains how to configure a bond interface in Ubuntu using Netplan.
What is Network Bonding?
Network bonding, also known as link aggregation, combines multiple network interfaces into a single logical interface. Benefits include:
- Increased throughput: Aggregate bandwidth from multiple links.
- Redundancy: Automatically failover if one link fails.
- Load balancing: Distribute traffic across multiple links.
Modes of Network Bonding
Ubuntu supports several bonding modes. Common ones include:
- Mode 0 (balance-rr): Round-robin policy for load balancing.
- Mode 1 (active-backup): Active-passive redundancy.
- Mode 2 (balance-xor): XOR policy for load balancing.
- Mode 4 (802.3ad): IEEE 802.3ad link aggregation (requires switch support).
- Mode 5 (balance-tlb): Adaptive transmit load balancing.
- Mode 6 (balance-alb): Adaptive load balancing with receive-side balancing.
Prerequisites
Before starting, ensure:
- Multiple network interfaces: Two or more NICs (e.g.,
eth0
,eth1
). - Root privileges: You'll need
sudo
access. - Netplan installed: Default network configuration tool in Ubuntu 18.04 and later.
Step-by-Step Guide to Configure Bond Interface
1. Identify Network Interfaces
Use the following command to list all network interfaces:
ip link show
Identify the interfaces you want to bond (e.g., eth0
and eth1
).
2. Edit Netplan Configuration
Open or create a Netplan configuration file in /etc/netplan/
(e.g., /etc/netplan/01-netcfg.yaml
).
Below is an example configuration for a bonded interface:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
eth1:
dhcp4: no
bonds:
bond0:
dhcp4: yes
interfaces:
- eth0
- eth1
parameters:
mode: active-backup
primary: eth0
- Replace
bond0
with your desired bond name. - Adjust
mode
as per your needs (e.g.,balance-rr
for load balancing). - Set
primary
for failover in active-backup mode.
3. Apply the Configuration
Apply the Netplan configuration with:
sudo netplan apply
4. Verify the Bonding Configuration
Check the bond status with:
cat /proc/net/bonding/bond0
This will display detailed bonding information, including the mode and active interfaces.
Additional Considerations
Switch Configuration
If using 802.3ad (LACP), configure the switch to support link aggregation.
Troubleshooting
- Network downtime: Ensure correct syntax in the YAML file.
- Interface not active: Check interface status with
ip link
.
Enhance Your Network Monitoring with AI
Managing network reliability can be challenging. Streamline monitoring and incident response with BrendanAI. BrendanAI predicts failures, assists with root cause analysis, and improves system reliability.
Conclusion
Configuring a bond interface in Ubuntu is straightforward with Netplan. Network bonding boosts performance, ensures redundancy, and optimizes traffic. By following this guide, you'll achieve a more reliable and robust network configuration.
Try BrendanAI to take your network reliability to the next level. Explore BrendanAI.