Skip to main content
RunBook Academy

LinuxXXI · Advanced Linux NetworkingBridge

Linux bridges and bridge VLANs

Intermediate⏱ ~12 minipbridge

What you'll learn

  • Create a Linux bridge with ip link
  • Attach interfaces and VLAN subinterfaces to a bridge
  • Configure bridge VLAN filtering for trunk ports
  • Recognise when a bridge is the right abstraction
  • Decide whether STP is needed, and enable it explicitly - it is off by default
  • Read bridge port states correctly: blocking, disabled, forwarding

Prerequisites

Verified against Ubuntu 24.04 LTS · Debian 12 (Bookworm) · RHEL 9.x · Rocky Linux 9.x · AlmaLinux 9.x · Linux kernel 6.1 LTS / 6.6 LTS · systemd 255+ · OpenSSH 8.7p1 (RHEL 9) / 9.6p1 (Ubuntu 24.04) · nftables 1.0.x · chrony 4.x · Pacemaker 2.1.x · Corosync 3.1.x · 2026-08-09

Not yet marked complete on this device.

A Linux bridge is a software implementation of an Ethernet switch. It connects multiple interfaces at layer 2 and forwards frames between them based on MAC addresses. Bridges are the foundation of KVM/libvirt networking, container networks (Docker bridge, CNI), and many virtualisation stacks.

Create a bridge

ip link add br0 type bridge
ip link set br0 up
ip addr add 10.0.0.10/24 dev br0
ip route add default via 10.0.0.1 dev br0

The bridge br0 now acts like a switch. You can attach physical interfaces or VLAN subinterfaces to it.

Attach interfaces

ip link set eth0 master br0
ip link set eth1 master br0

Both interfaces now forward frames into the bridge. To detach:

ip link set eth0 nomaster

A host’s main IP is usually on the bridge, not on the underlying physical interfaces. The physical interfaces become “bridge ports” with no IP of their own.

Inspect

ip link show master br0
bridge link show
bridge fdb show                # forwarding database
bridge vlan show

The forwarding database (FDB) is the bridge’s MAC table: which MAC is reachable on which port. Entries age out after 5 minutes by default.

Bridge VLAN filtering

By default a bridge forwards all VLAN tags between ports. To restrict which VLANs each port carries, enable VLAN filtering:

ip link set br0 type bridge vlan_filtering 1

Then set per-port VLAN membership:

bridge vlan add dev eth0 vid 100 pvid untagged
bridge vlan add dev eth0 vid 200
bridge vlan add dev eth1 vid 200 pvid untagged

pvid untagged means “frames arriving without a tag on this port are assigned VLAN 100”. vid 100 without untagged means “frames arriving tagged with VLAN 100 are forwarded”.

A trunk port has pvid untagged for the native VLAN and vid for every VLAN it carries. An access port has pvid untagged for one VLAN and no others.

Configure with Netplan

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
    eth1:
      dhcp4: no
  bridges:
    br0:
      addresses:
        - 10.0.0.10/24
      routes:
        - to: default
          via: 10.0.0.1
      interfaces:
        - eth0
        - eth1

For VLAN filtering:

  bridges:
    br0:
      addresses:
        - 10.0.0.10/24
      interfaces:
        - eth0
        - eth1
      vlans:
        - id: 100
          member:
            port: eth0
        - id: 200
          member:
            port: eth0
            vlan: 
              - eth0
              - eth1

Configure with systemd-networkd

A .netdev file creates the bridge:

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

[Bridge]
VLANFiltering=true

A .network file attaches the ports:

# /etc/systemd/network/11-br0.network
[Match]
Name=br0

[Network]
Address=10.0.0.10/24
Gateway=10.0.0.1

And for each port, the .network file has:

# /etc/systemd/network/12-eth0.network
[Match]
Name=eth0

[Network]
Bridge=br0

Use cases

  • Virtualisation host: KVM/QEMU uses bridges to attach VMs to the network. Each VM gets a tap interface on the bridge.
  • Container host: Docker creates a bridge by default for container networking.
  • Bond + VLAN aggregation: a bond becomes a bridge port, carrying multiple VLANs.
  • Network namespaces: bridges can span namespaces for complex topologies.

Knowledge check

Knowledge check · 5 questions

  1. Q1. How do you attach eth0 to a bridge br0?

  2. Q2. A newly created Linux bridge has Spanning Tree Protocol switched off until you enable it yourself.

  3. Q3. Which of the following can use a Linux bridge? Select all that apply.

  4. Q4. A bridged VM host has one link up but passing no traffic. bridge link show reports that port as "disabled". What have you learned?

  5. Q5. You are building a KVM host that will get a second uplink into the same VLAN next quarter. What do you do about STP on br0 today, and why?

Passing score: 75%. Answers are checked in this browser.