Installation and Features
Installing bridge-utils:
sudo apt install bridge-utils
Notes:
- Wi-Fi may not work correctly with bridges or may not connect at all.
- The IP address should only remain on the bridge; the main interface should not have an IP.
Information Commands
ifconfig -a— show all interfacesbrctl show— show bridgesbrctl showmacs— show MAC addresses on bridges
Main brctl Commands
brctl addbr <bridge>— create a bridgebrctl delbr <bridge>— delete a bridgebrctl addif <bridge> <device>— add an interface to the bridgebrctl delif <bridge> <device>— remove an interface from the bridgebrctl stp <bridge> {on|off}— enable/disable STP
Configuration Practice
Option 1: Manual Configuration via brctl
- Disable the interface:
ifconfig eth0 downorifdown eth0. - Create a bridge:
brctl addbr br0. - Add the interface to the bridge:
brctl addif br0 eth0. - Enable the bridge:
ifconfig br0 uporifup br0.
Option 2: Using Network Manager
auto br0
iface br0 inet dhcp
bridge_ports eno1
For static configuration:
auto br0
iface br0 inet static
address 192.168.2.23
broadcast 192.168.2.255
netmask 255.255.255.0
gateway 192.168.2.254
bridge_ports eno1
Option 3: Using Netplan
network:
version: 2
renderer: NetworkManager
ethernets:
eth0:
dhcp4: no
bridges:
br0:
dhcp4: yes
interfaces:
- eth0
Notes
- Use
netplan tryto test the configuration (rollback in 2 minutes). - Apply settings with
netplan apply.