brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: netplan bonds with active-backup keep a server online when one cable fails

Netplan
~/tips/tip-netplan-bond-active-backup

mode: active-backup

Combine two ports so the second takes over when the first link drops.

Two network ports can act as one connection, with the second waiting in reserve. The active-backup mode does that without any special switch support, which is why I would start there.

Declare the two ports under ethernets and give the address settings to the bond:

network:
  version: 2
  ethernets:
    enp3s0: {}
    enp4s0: {}
  bonds:
    bond0:
      interfaces: [enp3s0, enp4s0]
      dhcp4: true
      parameters:
        mode: active-backup
        primary: enp3s0
        mii-monitor-interval: 100

primary names the port to prefer. mii-monitor-interval is how often the link is checked, in milliseconds here. Set it: the default is 0, which turns link monitoring off, and then the bond has no way to notice a dead cable.

Apply it with the safety net, because you are moving the address to a new interface:

sudo netplan try

Netplan may not be able to roll a bond back cleanly, so I would do this with a console or physical access available.

The state of the bond is readable in /proc/net/bonding/bond0, including which port is active. Note that active-backup gives you failover only. It does not add bandwidth, since one port carries the traffic at a time.

Further reading: Netplan YAML reference

More Netplan tips – to: 192.168.3.0/24 hidden: true lacp-rate: fast link-local: [] wakeonlan: true All Netplan tips (21) All topics

Link