VLAN bridges on a virtualization host with Netplan

Run a VLAN trunk over a bond and assign each VM network its own bridge.

Two physical ports form an LACP bond to the switch. The bond carries tagged networks. Each guest VLAN gets its own bridge, while management has a separate VLAN and host address.

Configuration

# /etc/netplan/10-host.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0f0: {}
    enp1s0f1: {}
  bonds:
    bond0:
      interfaces: [enp1s0f0, enp1s0f1]
      parameters:
        mode: 802.3ad
        transmit-hash-policy: layer3+4
        lacp-rate: fast
  vlans:
    bond0.10: { id: 10, link: bond0 }
    bond0.20: { id: 20, link: bond0 }
  bridges:
    br-mgmt:
      interfaces: [bond0.10]
      addresses: [10.10.10.21/24]
      routes: [{ to: default, via: 10.10.10.1 }]
      nameservers: { addresses: [10.10.10.53] }
    br-vm20:
      interfaces: [bond0.20]
      parameters: { stp: false, forward-delay: 0 }

Applying the configuration

netplan generate        # check configuration syntax
netplan try --timeout 120

netplan try asks for confirmation and attempts to roll back if you do not confirm within the timeout. For remote changes, keep console access available.

Spanning tree

The example turns STP off on its VM bridges. Do this only when those bridges cannot form Layer 2 loops.

Verification

networkctl status bond0
cat /proc/net/bonding/bond0
bridge vlan show
ip -br addr