Modern Layer 2 Ethernet Bridge Management in Linux
Software bridges in Linux act as virtual network switches, aggregating physical Ethernet interfaces, virtual Ethernet pairs (veth), and TAP devices into unified Layer 2 broadcast domains. While legacy deployments relied on the outdated brctl utility from the bridge-utils package, modern Linux distributions manage software bridges using the dedicated bridge utility included in the iproute2 suite. The bridge command provides kernel-level visibility and precise configuration controls for Forwarding Database (FDB) MAC address tables, port states, Spanning Tree Protocol (STP) parameters, and advanced 802.1Q VLAN filtering.
The Role of the bridge Command in iproute2
Just as ip replaced ifconfig and route, the bridge tool supersedes brctl by interfacing directly with modern kernel Netlink sockets. While creating a bridge device itself is executed using ip link add name br0 type bridge, all Layer 2 switching behaviour occurring inside that bridge—such as port hairpinning, MAC learning rules, multicast snooping, and VLAN tagging—is configured and monitored through the bridge command.
Inspecting Bridge Interfaces and Member Slave Ports
To inspect active bridge members and review physical or virtual interfaces enslaved to a bridge, use the bridge link subcommand.
bridge link show
The output enumerates each slave interface attached to a bridge alongside its operational flags:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 4
3: veth-web: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 2
Here you can observe the port’s master bridge (master br0), its operational spanning tree state (state forwarding, learning, or blocking), and port path cost metrics.
Inspecting and Managing the Forwarding Database (FDB)
The Forwarding Database (FDB) is the bridge’s internal MAC address lookup table. When an Ethernet frame enters a bridge port, the kernel records the sender’s MAC address in the FDB to route subsequent return traffic directly to that specific port rather than flooding the entire broadcast domain.
Viewing Dynamic and Static MAC Addresses
To inspect the entire MAC forwarding table, run:
bridge fdb show
To restrict output to a specific bridge interface:
bridge fdb show br br0
Entries tagged as permanent represent the bridge’s own interface MACs, while entries marked as offload or dynamic entries represent learned host devices on attached local subnets.
Adding Static FDB MAC Entries
In secure environments, you can manually pin a host’s MAC address to a designated port to prevent MAC spoofing and switch port stealing attacks:
sudo bridge fdb add 00:11:22:33:44:55 dev eth0 permanent
Flushing Learned MAC Addresses
If network cabling changes cause stale MAC routes, flush dynamically learned records immediately without rebooting:
sudo bridge fdb flush dev br0
Configuring VLAN Filtering on Linux Bridges
Modern Linux bridges support hardware-accelerated VLAN filtering, allowing a single bridge instance to handle multiple isolated 802.1Q VLAN tags without creating dozens of complex sub-interfaces. Ensure VLAN filtering is enabled on your bridge:
sudo ip link set dev br0 type bridge vlan_filtering 1
Displaying Active Bridge VLANs
To inspect which VLANs are permitted through specific bridge ports:
bridge vlan show
Assigning Trunk and Access VLAN Ports
To configure an access port that untags traffic for VLAN 10 (PVID):
sudo bridge vlan add vid 10 dev veth-db pvid untagged
To configure a trunk port allowing tagged frames for VLAN 10 and VLAN 20 across an uplink interface:
sudo bridge vlan add vid 10 dev eth0
sudo bridge vlan add vid 20 dev eth0
Monitoring Spanning Tree Protocol (STP) Bridge States
When bridging multiple physical network adapters, network loops can cause catastrophic packet broadcast storms. You can monitor port transitions and adjust bridge-level parameters using bridge monitor to listen for real-time topology change notifications (TCN):
sudo bridge monitor fdb
This command streams real-time console updates whenever a new MAC address is registered, modified, or expired from the switching table.
Essential Command Summary for Network Engineers
Mastering the bridge command provides comprehensive control over Linux virtualization and container networking stacks. Whether isolating container network namespaces with VLAN filtering or debugging MAC migration in virtual machine clusters, bridge provides the speed and granularity required for modern production infrastructure.