Ubuntu 22.04 LTS and Netplan

Building a Bonded Interface in Netplan: Avoiding Common Pitfalls and Best Practices

As a Data Protection Consultant, I recently encountered issues while building a bonded interface for a server using Netplan. In this article, I will share my experiences and the solutions I found to help you avoid common pitfalls and best practices when working with Netplan.

Background Information

———————

I was tasked with creating a simple active-backup bonded interface, so that if one NIC fails, another interface should carry on serving traffic. When working with network switches of questionable quality, I prefer using a simpler active-backup network resiliency mechanism instead of configuring active-active methods that can cause compatibility issues between the server OS and switch.

Monitoring Interface Failure

—————————

There are two ways to monitor interface failure in Netplan:

### MII Monitoring

MII (Media Independent Interface) monitoring is the process of checking the physical connection state of your network interface. This method works well with copper interfaces, but it can be unreliable with optical connections. If your fibre module is present but the optical connection isn’t within your interface, it can still report as “UP” even though you can’t pass traffic via the interface, which can cause outages.

### ARP Monitoring

ARP (Address Resolution Protocol) monitoring is the use of sending ARP requests to one or more IP addresses and confirming network health via the reachability to other network resources. This method is more reliable than MII monitoring, as it can confirm whether the interface is capable of reaching devices. You can also specify whether all ARP targets must be up for the interface to be healthy or if the response of any is sufficient.

Configuring Bonded Interfaces with Netplan

——————————————

When configuring bonded interfaces using Netplan, it’s essential to choose either MII or ARP monitoring, as combining both can cause issues. Here are some examples of both:

### MII Monitoring Example

“`

network:

version: 2

renderer: networkd

ethernets:

bond0:

dhcp4: yes

dhcp6: yes

mii-monitor-interval: 100

mii-full-duplex: true

mii-speed: 10000

“`

### ARP Monitoring Example

“`

network:

version: 2

renderer: networkd

ethernets:

bond0:

dhcp4: yes

dhcp6: yes

arp-targets:

– 192.168.1.1

– 192.168.1.2

arp-interval: 100

arp-full-duplex: true

arp-speed: 10000

“`

Troubleshooting Tips and Commands

———————————-

To assist with any troubleshooting, here are some useful commands:

### Generate Netplan Configuration with Debug Output

“`

sudo netplan –debug generate

“`

### Apply Netplan Configuration with Debug Output

“`

sudo netplan –debug apply

“`

### Confirm Current Configuration of Bonded Network Interface

“`

sudo ip link show bond0

“`

### Confirm Which Interfaces Are UP or DOWN

“`

sudo ip addr show dev bond0

“`

Best Practices and Conclusion

——————————

In conclusion, when configuring bonded interfaces using Netplan, it’s essential to choose either MII or ARP monitoring and avoid combining both. This article has highlighted common pitfalls and best practices for building a bonded interface in Netplan. By following these tips and commands, you can ensure your configurations have taken effect and avoid any potential outages caused by interface failure monitoring.

I hope this article helps the next person struggling with this configuration to get up and running quickly! Now, I’m off to ask Canonical to update their documentation to reflect this information.