brctl

networkingLinux
The brctl command is one of the most frequently used commands in Linux/Unix-like operating systems. brctl Ethernet bridge administration tool for Linux

Quick Reference

Command Name:

brctl

Category:

networking

Platform:

Linux

Basic Usage:

brctl [options] [arguments]

Common Use Cases

    Syntax

    brctl [OPTIONS] COMMAND [BRIDGE] [INTERFACE]

    Options

    Command Description
    addbr BRIDGE Create a new bridge device
    delbr BRIDGE Delete the specified bridge device
    addif BRIDGE INTERFACE Add the interface to the bridge
    delif BRIDGE INTERFACE Remove the interface from the bridge
    show [BRIDGE] Show all bridges or the specified bridge details
    stp BRIDGE {on|off} Enable/disable the Spanning Tree Protocol
    showstp BRIDGE Show STP information for the specified bridge
    setfd BRIDGE TIME Set bridge forward delay time in seconds
    showmacs BRIDGE Show MAC addresses learned by the bridge

    Examples

    How to Use These Examples

    The examples below show common ways to use the brctl command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    brctl show
    Display all bridges and their associated interfaces.
    brctl addbr br0
    Create a new bridge called br0.
    brctl delbr br0
    Delete the bridge br0. brctl addif br0 eth0 Add the interface eth0 to the bridge br0. # Advanced Examples Advanced brctl delif br0 eth0 Remove the interface eth0 from the bridge br0. brctl stp br0 on Enable the Spanning Tree Protocol on bridge br0. brctl setfd br0 10 Set the bridge forward delay to 10 seconds. brctl showmacs br0 Show the MAC addresses learned by the bridge.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The brctl command is used to manage Ethernet bridges in Linux. An Ethernet bridge is a device that connects multiple network segments at the data link layer (Layer 2) of the OSI model. Note that brctl is considered deprecated in modern Linux distributions. The recommended replacement is the 'bridge' command from the iproute2 package. Common uses of brctl include: - Setting up a software bridge for virtual machines - Creating network configurations for containers - Implementing network bridging between physical and virtual interfaces The bridge must be created before interfaces can be added to it, and all interfaces must be removed before a bridge can be deleted. For STP (Spanning Tree Protocol) settings to take effect, STP must be enabled on the bridge with the 'stp on' command.

    Related Commands

    These commands are frequently used alongside brctl or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the brctl command works in different scenarios.

    $ brctl
    View All Commands