Network bridging involves associating two networks that normally would not pass network traffic between them. Bridging works at OSI Layer 2 with MAC addresses. A Linux system can be configured to bridge two networks. The brctl (bridge control) command is used to configure bridging within Linux.
A common example of bridging is as follows:
- brctl show — View the bridging configuration.
- brctl addbr {bridge name} — Create an empty bridge.
- brctl addif {bridge name} eth0 — Add eth0 to the bridge.
- brctl addif {bridge name} eth1 — Add eth1 to the bridge, linking the networks connected to eth0 and eth1.
Syntax
The syntax of the brctl command is:
# brctl [command]
If you encounter the below error while running the brctl command:
brctl: command not found
you may try installing the below package as per your choice of distribution:
OS Distribution | Command |
---|---|
Debian | apt-get install bridge-utils |
Ubuntu | apt-get install bridge-utils |
Alpine | apk add bridge-utils |
Arch Linux | pacman -S bridge-utils |
Kali Linux | apt-get install bridge-utils |
CentOS | yum install bridge-utils |
Fedora | dnf install bridge-utils |
Raspbian | apt-get install bridge-utils |
brctl Command Examples
1. Show a list with information about currently existing Ethernet bridges:
# brctl show
2. Create a new Ethernet bridge interface:
# brctl add bridge_name
3. Delete an existing Ethernet bridge interface:
# brctl del bridge_name
4. Add an interface to an existing bridge:
# brctl addif bridge_name interface_name
5. Remove an interface from an existing bridge:
# brctl delif bridge_name interface_name