Andrew Mercer
on this page

What it is

The Linux bridge is an in-kernel software implementation of a Layer 2 switch — think of it as a virtual switch chassis, with physical NICs and virtual (tap/veth) interfaces as the cables plugged into it. It's the standard way to give VMs and containers real presence on the physical LAN, and the building block underneath most virtualization networking (libvirt, Docker's bridge driver).

Installing bridge-utils

sudo yum -y install bridge-utils      # RHEL/CentOS (legacy tool; `ip link` covers most of this natively on modern kernels)

Modern systems can create and manage bridges entirely through ip link / iproute2 without bridge-utils — see below.

Creating a bridge with iproute2 (modern approach)

sudo ip link add name br0 type bridge
sudo ip link set br0 up
sudo ip link set eth0 master br0        # attach a physical NIC to the bridge
sudo ip addr add 192.168.0.50/24 dev br0

Legacy: RHEL/CentOS sysconfig network-scripts

Still relevant on older RHEL-family systems using the legacy network service instead of NetworkManager:

cat /etc/sysconfig/network-scripts/ifcfg-eth0
NAME="eth0"
DEVICE="eth0"
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
NM_CONTROLLED=no
BRIDGE="br0"
cat /etc/sysconfig/network-scripts/ifcfg-br0
NAME="br0"
DEVICE="br0"
ONBOOT=yes
BOOTPROTO=dhcp
TYPE="Bridge"
DNS1="192.168.0.1"

For managing bridges via NetworkManager instead (the modern, distro-agnostic path), see the nmcli guide.

Inspecting a bridge

bridge link show              # port membership
bridge fdb show br br0        # forwarding database (learned MAC addresses)
ip -d link show br0           # bridge details (STP state, etc.)

Cheat sheet

ip link add name br0 type bridge          # create bridge
ip link set eth0 master br0               # attach a NIC
bridge link show                          # inspect membership
bridge fdb show br br0                    # MAC learning table