LinuxCommandLibrary

brctl

Manage Ethernet bridges

TLDR

Show a list with information about currently existing Ethernet bridges

$ sudo brctl show
copy

Create a new Ethernet bridge interface
$ sudo brctl add [bridge_name]
copy

Delete an existing Ethernet bridge interface
$ sudo brctl del [bridge_name]
copy

Add an interface to an existing bridge
$ sudo brctl addif [bridge_name] [interface_name]
copy

Remove an interface from an existing bridge
$ sudo brctl delif [bridge_name] [interface_name]
copy

SYNOPSIS

brctl command [bridge-name] [interface-name] [parameters]

Examples of common usage patterns:
brctl addbr br0
brctl addif br0 eth0
brctl show
brctl stp br0 on

PARAMETERS

addbr
    Creates a new bridge device named bridge.

delbr
    Deletes the bridge device named bridge.

addif
    Adds the network interface to the specified bridge.

delif
    Removes the network interface from the specified bridge.

show
    Lists all active bridge devices, their interfaces, and basic configuration.

showmacs
    Displays the MAC addresses learned by the specified bridge.

showstp
    Shows Spanning Tree Protocol (STP) information for the specified bridge.

setageing
    Sets the MAC address aging time for the bridge in seconds.

setfd
    Sets the forwarding delay for the bridge in seconds (for STP).

sethello
    Sets the hello time for STP on the bridge in seconds.

setmaxage
    Sets the maximum message age for STP on the bridge in seconds.

setbridgeprio
    Sets the bridge's STP priority (0-65535, lower is higher priority).

setportprio
    Sets a specific port's STP priority on the bridge.

stp {on|off}
    Enables or disables Spanning Tree Protocol (STP) on the specified bridge.

DESCRIPTION

The brctl command-line utility is used to create, manage, and configure Ethernet bridge devices on Linux systems.

An Ethernet bridge acts as a software switch, forwarding network traffic between different network interfaces (physical or virtual) to combine them into a single logical network segment. This is particularly useful in virtualization environments, such as with KVM or LXC containers, where virtual machines or containers need to connect to the host's physical network.

While still functional, brctl is largely considered a legacy tool. Modern Linux distributions often prefer the more comprehensive iproute2 suite, specifically the ip link and ip bridge commands, for network configuration tasks. However, brctl remains straightforward for basic bridge management.

CAVEATS

Legacy Tool: brctl is largely superseded by the iproute2 suite (e.g., ip link) for modern Linux network configuration.
Persistent Configuration: Commands executed with brctl are not persistent across reboots. For permanent changes, integrate them into your system's network configuration files (e.g., /etc/network/interfaces on Debian/Ubuntu, /etc/sysconfig/network-scripts on RHEL/CentOS, or Netplan on newer systems).
IP Addressing: Adding an interface to a bridge causes the interface to lose its individual IP configuration. The bridge itself usually requires an IP address for the host to communicate on that network segment.

UNDERSTANDING ETHERNET BRIDGES

An Ethernet bridge operates at Layer 2 of the OSI model, acting as a software switch. It inspects MAC addresses to intelligently forward frames between connected interfaces, rather than simply broadcasting all traffic. This allows multiple network segments (e.g., physical NICs, virtual Ethernet devices) to behave as if they are on the same local area network (LAN).

SPANNING TREE PROTOCOL (STP)

STP (802.1D) is a network protocol that ensures a loop-free topology for Ethernet networks. When multiple paths exist between network segments (e.g., redundant links), STP logically blocks redundant paths to prevent broadcast storms and MAC address table instability. brctl provides commands to enable/disable STP and configure its parameters like forwarding delay, hello time, and bridge/port priorities.

HISTORY

brctl is part of the bridge-utils package, which has been a staple in Linux networking for managing Ethernet bridges for many years. It was the primary tool for this purpose before the more unified iproute2 utilities became prevalent. Its development has slowed, with ip link and ip bridge becoming the preferred methods for advanced bridge management and configuration.

SEE ALSO

ip(8), bridge(8), netplan(5), ifconfig(8)

Copied to clipboard