Network bonding on Ubuntu allows you to combine multiple network interfaces into a single logical interface. This setup increases bandwidth, provides redundancy, and improves network reliability by enabling failover between interfaces. It’s especially useful in environments where uptime and performance are critical, such as servers or professional workstations.
What You’ll Need
- An Ubuntu system (desktop or server) with at least two network interfaces (NICs) available for bonding.
- Root or sudo privileges to modify network configurations.
- Basic familiarity with the Linux command line and file editing.
- Access to your network’s switch or router (optional but recommended to configure switch-side bonding modes if needed).
Step-by-Step
- Check your network interfaces: Open a terminal and run
ip link showorifconfig -ato list all network interfaces. Identify the interfaces you want to bond (e.g.,eth0andeth1). - Install ifenslave package: This utility is required to manage bonded interfaces. Run
sudo apt updatefollowed bysudo apt install ifenslave. - Load bonding kernel module: Run
sudo modprobe bondingto activate the bonding driver. To make it load on boot, addbondingto/etc/modulesby runningecho bonding | sudo tee -a /etc/modules. - Backup current network config: Before making changes, backup your existing network configuration files, e.g.,
sudo cp /etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml.bakor the appropriate config file for your Ubuntu version. - Edit netplan configuration: Ubuntu 18.04 and newer use Netplan for network configuration. Open your netplan YAML file with
sudo nano /etc/netplan/01-netcfg.yaml(filename may differ).- Define a bonded interface (e.g.,
bond0) with your chosen mode (see bonding modes below). - Specify the member interfaces (e.g.,
eth0andeth1).
Example configuration:
network: version: 2 renderer: networkd ethernets: eth0: {} eth1: {} bonds: bond0: interfaces: [eth0, eth1] parameters: mode: active-backup primary: eth0 mii-monitor-interval: 100 dhcp4: yesThis example uses
active-backupmode with DHCP enabled. - Define a bonded interface (e.g.,
- Apply the network configuration: Run
sudo netplan apply. This command will activate the bonding interface and bring down individual interfaces under it. - Verify bonding status: Check if the bond is up and the slave interfaces are attached with
cat /proc/net/bonding/bond0. This file shows bonding mode, active slave, and link status. - Configure switch (optional): If your bonding mode requires switch support (e.g.,
802.3adfor LACP), ensure your network switch is configured to support link aggregation for the ports connected to your Ubuntu system. - Test failover: Disconnect one network cable and verify that network connectivity continues without interruption, confirming the bond is working as expected.
Common Mistakes
- Not backing up network config files: Changes can disrupt connectivity; always backup before editing.
- Incorrect YAML syntax: Netplan files are sensitive to indentation and formatting errors, leading to failed applies.
- Using incompatible bonding modes without switch support: Modes like
802.3adrequire switch configuration; otherwise, the bond won’t work correctly. - Forgetting to load the bonding module: Without it, bonding interfaces won’t function.
- Not specifying all slave interfaces in the bond: Leaving out an interface means it won’t be part of the bond.
- Assuming bonding increases speed automatically: Some modes only provide failover, not aggregated bandwidth.
Tips
- Choose the right bonding mode: For simple failover, use
active-backup. For load balancing or aggregation, considerbalance-rr,balance-xor, or802.3adwith switch support. - Use
mii-monitor-intervalto monitor link health: This setting controls how often the link is checked and helps with faster failover. - Test changes on a non-production system first: To avoid downtime, try bonding on a test machine or during maintenance windows.
- Use
ip aandip linkcommands frequently: They help diagnose interface and bonding status quickly. - Keep your system and packages updated: Newer kernel and netplan versions have improved bonding support and bug fixes.
- Document your configuration changes: This helps maintain clarity if you revisit or troubleshoot later.
Troubleshooting
If your network bonding does not work as expected, try the following steps:
- Check kernel module: Run
lsmod | grep bondingto confirm the bonding module is loaded. If it’s not, runsudo modprobe bonding. - Validate netplan YAML syntax: Use
sudo netplan tryto test configuration before applying, catching syntax errors. - Inspect bond status: View
/proc/net/bonding/bond0for detailed info on slaves and mode. - Verify IP assignment: Make sure the bonded interface has a valid IP address via DHCP or static config.
- Check physical connections: Ensure all cables and ports are connected and functioning.
- Review switch configuration: For modes like
802.3ad, confirm the switch ports are set up for link aggregation. - Restart networking services: Sometimes, restarting with
sudo systemctl restart systemd-networkdor rebooting helps apply changes cleanly. - Look at system logs: Check
journalctl -xeor/var/log/syslogfor network-related errors.
Frequently Asked Questions
What is network bonding, and why should I use it?
Network bonding combines multiple network interfaces into one logical interface to increase bandwidth, provide redundancy, and improve fault tolerance.
Can I bond wireless interfaces on Ubuntu?
Bonding wireless interfaces is generally not supported or recommended due to the nature of wireless connections and driver limitations.
What bonding mode should I choose for simple failover?
Use active-backup mode, which keeps one interface active and switches to another if it fails.
Does bonding always increase my network speed?
Not necessarily. Some modes provide failover only, while others can aggregate bandwidth depending on switch support and configuration.
Do I need to configure my network switch for bonding to work?
For some modes like 802.3ad (LACP), yes. Other modes like active-backup do not require switch configuration.
How can I check if my bonded interface is working correctly?
Check /proc/net/bonding/bond0 for status details and test failover by disconnecting one cable to see if the connection persists.
By following these steps and tips, even beginners can successfully set up network bonding on Ubuntu, improving their network’s reliability and performance with minimal hassle.
For extra practice, you might try creating a static IP bonded interface or experimenting with different bonding modes to see how they affect traffic and failover behavior.
Remember, network bonding is a powerful tool, but it requires careful configuration, especially when working with network switches and production environments.
Related
- How to Connect Cardboard: 9 Essential Cardboard Joinery Techniques
- How to Ripen Figs at Home: A Simple Step-by-Step Guide
- How to Install OSMC (Formerly Raspbmc) on Your Raspberry Pi