smalllife // packet & bench

One VLAN-aware Linux bridge instead of four separate sub-bridges

2026-03-07 · linux, bridging, systemd-networkd

The older Linux habit for tagged trunks is stacking VLAN sub-interfaces (enp2s0.10, enp2s0.20) and enslaving each pair into its own bridge (br10, br20). It works, but ip link quickly turns into wallpaper and STP runs per bridge instead of across physical ports.

Since Linux 3.8, the in-kernel bridge supports native 802.1Q filtering (vlan_filtering=1), making it behave like a normal managed switch: one bridge device, per-port PVID and allowed VLAN bitmaps, and VLAN interfaces attached on top of br0 only for subnets where the router itself needs an IP.

systemd-networkd layout

Setting DefaultPVID=none on br0.netdev avoids accidentally dropping VLAN 1 onto every member port before explicit VLAN stanzas apply:

# /etc/systemd/network/10-br0.netdev
[NetDev]
Name=br0
Kind=bridge

[Bridge]
VLANFiltering=yes
DefaultPVID=none
STP=no

Trunk port to sw01 carries VLANs 10 (trusted), 20 (iot), and 99 (mgmt), all tagged:

# /etc/systemd/network/20-enp2s0-trunk.network
[Match]
Name=enp2s0

[Network]
Bridge=br0

[BridgeVLAN]
VLAN=10

[BridgeVLAN]
VLAN=20

[BridgeVLAN]
VLAN=99

Spare port enp3s0 stays untagged in VLAN 99 so a laptop with no VLAN config can always reach SSH during maintenance:

# /etc/systemd/network/21-enp3s0-rescue.network
[Match]
Name=enp3s0

[Network]
Bridge=br0

[BridgeVLAN]
VLAN=99
PVID=99
EgressUntagged=99

Checking the hardware/forwarding table

$ bridge vlan show
port              vlan-id
enp2s0            10
                  20
                  99
enp3s0            99 PVID Egress Untagged
br0               10
                  20
                  99

Remember the self-membership detail: if the host routes VLAN 10 via vlan10@br0, br0 itself must also have [BridgeVLAN] VLAN=10 in br0.network, otherwise frames enter the bridge from enp2s0 and never pass up to the local L3 stack.