Skip to main content
In this lesson, you will learn how to bridge and bond network interfaces using Netplan on Ubuntu. We’ll start by exploring example YAML configuration files, then modify them to suit your network configuration. This guide is perfect for network administrators looking to optimize connectivity using bridges and bonded devices.

Inspecting the Bridge Example

Begin by reviewing the example bridge configuration file located at /usr/share/doc/netplan/examples/bridge.yaml:
This configuration defines a single Ethernet interface (enp3s0) with DHCP disabled, and a bridge (br0) that obtains an IP address via DHCP. This file serves as our starting template.
Before making any modifications, verify that the network interfaces referenced in the configuration match your system’s hardware.

Copying and Securing the Configuration File

Copy the example file to the Netplan configuration directory and set secure permissions:

Identifying Network Interfaces

Determine the network interface names in your system with:
Note that enp0s3 is used for primary connectivity (e.g., SSH access) and should not be modified to avoid disconnection. In this lesson, we will use enp0s8 and enp0s9 for the bridge.

Editing the Netplan File for Bridging

Update the Netplan configuration to create a bridge that combines enp0s8 and enp0s9. Disable DHCP on the individual Ethernet interfaces and enable it solely on the bridge:
Save the file and apply the configuration. Verify the network interface statuses with:
This output shows that enp0s8 and enp0s9 are now slaves to the bridge br0, which is assigned an IP address via DHCP.

Reverting the Bridge Configuration

To remove the bridge configuration and free up the network interfaces, simply delete the YAML file and remove the bridge interface:
For a complete reset of network settings in a production environment, consider rebooting the system after deleting the configuration.

Configuring Network Bonding

Next, let’s configure network bonding to provide redundancy and load balancing. Begin by copying the bonding example file and setting secure permissions:
Edit the bonding configuration file (/etc/netplan/99-bond.yaml) using your favorite text editor. The corrected configuration below ensures that the Ethernet interfaces are properly defined:
In this configuration:
  • The Ethernet interfaces enp0s8 and enp0s9 have DHCP disabled.
  • A bond named bond0 is configured with DHCP enabled.
  • The bonding mode is set to active-backup (Mode 1) with enp0s8 designated as the primary interface.
  • The MII monitor checks link status every 100 milliseconds.
For additional bonding modes (such as balance-rr, balance-xor, broadcast, 802.3ad, balance-tlb, or balance-alb), review the bonding documentation and adjust the parameters accordingly.
For a deeper understanding of the bonding options and Netplan configuration, consult the manual by running:sudo man netplanThen search for “bonding” within the manual.
Apply the new Netplan configuration:
After applying the changes, confirm the bonding setup with:
This output indicates that both enp0s8 and enp0s9 are slaves of bond0, which is receiving its IP configuration via DHCP.

Viewing Bond Details

To inspect the bond’s details, read the bond status file:
This file provides comprehensive information about the bond’s parameters and operating status.

Managing Bonded Interfaces

Bonded interfaces can be managed like regular Ethernet interfaces. For example, to bring the bond interface down and assign a static IP address, use:
Changes made with the IP command are temporary and will be reset after a system reboot.
Thank you for following this tutorial. Happy networking, and see you in the next article!

Watch Video