GekBuzz

Answers, Explainers & Everyday Guides

How to Configure Network Bonding or Teaming in Ubuntu

How to Configure Network Bonding or Teaming in Ubuntu

Network bonding or teaming in Ubuntu allows you to combine multiple network interfaces into a single logical interface. This setup can increase bandwidth, provide redundancy, and improve network reliability by ensuring continuous connectivity if one link fails. It is commonly used in servers, virtualization hosts, and critical network appliances.

What You’ll Need

  • Ubuntu system (desktop or server) with at least two network interfaces
  • Root or sudo access to configure network settings
  • Basic familiarity with the command line and network configuration
  • Backup of existing network configuration files

Step-by-Step

  1. Check your network interfaces: Run ip link show or ifconfig -a to identify the interfaces you want to bond or team. Make sure they are not in use or configured with static IPs that might conflict.
  2. Install necessary packages: For bonding, the kernel module is usually included by default; for teaming, install the teamd daemon:
    sudo apt update && sudo apt install ifenslave teamd
  3. Load the bonding kernel module: Execute sudo modprobe bonding. To load it permanently, add bonding to /etc/modules:
    echo bonding | sudo tee -a /etc/modules
  4. Create a bonding interface configuration: Ubuntu uses Netplan by default (18.04+). Edit your Netplan config in /etc/netplan/ (e.g., 01-netcfg.yaml), or create a new file:
    network:
      version: 2
      renderer: networkd
      ethernets:
        enp3s0: {}
        enp4s0: {}
      bonds:
        bond0:
          interfaces: [enp3s0, enp4s0]
          parameters:
            mode: balance-rr
            primary: enp3s0
          dhcp4: yes

    Replace enp3s0 and enp4s0 with your interface names. The mode can be one of balance-rr, active-backup, 802.3ad (LACP), balance-xor, broadcast, or balance-tlb.

  5. Apply the Netplan configuration: Run sudo netplan apply. This will create and activate the bonded interface.
  6. Verify the bonding interface: Use cat /proc/net/bonding/bond0 to check status and active interfaces. Also, ip addr show bond0 should display the bonded interface with its IP.
  7. Configure teaming (optional alternative to bonding): Create a team configuration file, e.g., /etc/systemd/network/team0.netdev:
    [NetDev]
    Name=team0
    Kind=team

    Then create /etc/systemd/network/team0.network to assign IP and add slaves:

    [Match]
    Name=team0
    
    [Network]
    DHCP=yes

    And create slave configs for each interface, e.g., enp3s0.network:

    [Match]
    Name=enp3s0
    
    [Network]
    TeamSlave=yes

    Repeat for other interfaces. Restart systemd-networkd with sudo systemctl restart systemd-networkd.

  8. Test failover and bonding: Disconnect one cable or disable one interface and check if network stays up with ping or ip a.
  9. Make configurations persistent: Ensure your changes are saved and backed up. For older Ubuntu versions using ifupdown, bonding is configured in /etc/network/interfaces instead.

Common Mistakes

  • Not unloading or conflicting with existing network configurations before bonding.
  • Using incorrect interface names or typos in Netplan YAML files causing failed applies.
  • Forgetting to load the bonding kernel module or teamd service.
  • Choosing an inappropriate bonding mode without understanding switch support (e.g., 802.3ad requires switch LACP support).
  • Applying bonding without coordinating settings on the connected switch ports.
  • Not testing failover, leading to unnoticed single points of failure.

Tips

  • Always backup your current network configuration files before making changes.
  • Use balance-rr or active-backup modes if unsure, as they are simpler and widely supported.
  • Check switch compatibility and configuration when using LACP (802.3ad) mode.
  • Use ethtool to verify link status and speed on interfaces.
  • Monitor bonding interfaces with cat /proc/net/bonding/bond0 to confirm active slaves and errors.
  • For complex setups, consider teaming with teamd for more advanced features and control.
  • Use descriptive interface names to avoid confusion, especially on systems with many NICs.

Troubleshooting

If bonding or teaming does not work as expected, try these steps:

  • Check kernel modules: Ensure bonding module is loaded with lsmod | grep bonding. Load if missing: sudo modprobe bonding.
  • Inspect logs: Use journalctl -xe or dmesg for errors related to network or bonding.
  • Validate Netplan syntax: Run sudo netplan try to test config before applying permanently.
  • Verify interface states: Use ip link show and ethtool to confirm interfaces are up and operational.
  • Switch configuration: Confirm that your network switch ports are configured correctly, especially if using LACP bonding.
  • Restart networking: Restart systemd-networkd or networking service to reload configurations: sudo systemctl restart systemd-networkd or sudo systemctl restart networking.
  • Fallback to simple mode: Temporarily switch to active-backup mode to isolate issues with switch compatibility.
  • Check IP conflicts: Ensure no IP address conflicts exist on the network.

Frequently Asked Questions

What is the difference between bonding and teaming?

Bonding is a kernel-level method to aggregate network interfaces; teaming is a newer user-space alternative offering more flexible and modern features. Teaming uses the teamd daemon and systemd-networkd integration.

Do I need special hardware to use bonding or teaming?

No special hardware is required, but some bonding modes like 802.3ad (LACP) need your switch to support link aggregation protocols.

Can I bond interfaces with different speeds?

It is possible but not recommended. Bonding works best with identical or similar interface speeds to avoid performance issues and packet reordering.

Will bonding increase my network speed?

Bonding can increase throughput by combining multiple links, but actual speed depends on the mode used and switch support. Some modes provide redundancy rather than speed boost.

How do I check if bonding is working?

Use cat /proc/net/bonding/bond0 to see bonding status and active slaves. You can also test failover by disconnecting one link and verifying network continuity.

Can I configure bonding on a desktop Ubuntu system?

Yes, bonding or teaming can be configured on desktop systems, but it is more common on servers or systems requiring high availability or increased bandwidth.

Is it possible to use DHCP with bonded interfaces?

Yes, bonded interfaces can be assigned IP addresses via DHCP or static configuration depending on your network needs and Netplan or ifupdown settings.

By following these instructions and tips, you can successfully configure network bonding or teaming on your Ubuntu system to enhance network performance and reliability.

Related

How to Configure Network Bonding or Teaming in Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top