How to configure bridge with vlan information?
Environment
- Red Hat Enterprise Linux 10 (RHEL10)
- Red Hat Enterprise Linux 9 (RHEL9)
- Red Hat Enterprise Linux 8 (RHEL8)
- Linux bridge
- VLAN (802.1q)
Issue
- How to tag a
bridgeinterface withvlan id? - How to use
bridge.vlanoptions inbridgeinterface?
Resolution
- Create the Bridge interface.
# nmcli con add type bridge ifname br1 con-name br1 ip4 192.168.122.10/24 gw4 192.168.122.1 bridge.vlan-filtering 1 bridge.vlan-default-pvid 2012 bridge.stp no
-
The bridge default
PVIDis set to2012so that by default the incoming frames without aVLANtag are assigned internally toVLAN 2012. -
Disable
STPon thebridgeinterface so that thebridgedoesn't wait 15 seconds before starting to forward frames, and ping works immediately. Enable it again if you have a redundant topology and want to avoid loops. -
Create
VLANon top of ens8(setting thebridgebr1 as its master)
# nmcli con add type ethernet ifname ens8 master br1 slave-type bridge bridge-port.vlans 2012
-
The
bridge portis assigned to taggedVLAN 2012, which means that theVLANtag is added on outgoing frames. -
The type
bridge-slavesyntax is deprecated and is equivalent to type ethernetslave-type bridge. -
After the 2 connections are activated, you should see:
# bridge vlan
port vlan ids
ens8 2012
br1 2012 PVID Egress Untagged
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.