$ run as a normal user# run as root (or with sudo)
The quick answer
nmcli connection add type vlan con-name vlan20 ifname eth0.20 dev eth0 id 20 ipv4.method manual ipv4.addresses 10.20.0.15/24
nmcli connection up vlan20
nmcli connection add type bridge con-name br0 ifname br0 ipv4.method manual ipv4.addresses 192.168.1.10/24 ipv4.gateway 192.168.1.1 ipv4.dns 192.168.1.1 bridge.stp no
nmcli connection add type bridge-slave con-name br0-port1 ifname eth1 master br0
nmcli connection up br0Step by step
- Look first —
nmcli device statusandnmcli connection showlist interfaces and their profiles. Note the current IP, gateway and DNS. - VLAN (lines 1–2) — the switch port must carry VLAN 20 tagged (trunk). The new interface
eth0.20gets its own address;eth0keeps its untagged network. - Bridge (line 3) —
br0gets the IP address that the physical port had. STP off is fine for a simple host with one uplink. - Add the port (line 4) —
eth1becomes a member ofbr0and has no IP of its own any more. - Switch over without losing SSH — do it from the console, or in one command with a safety net:
echo "nmcli connection up 'Wired connection 2'" | at now + 5 minutes
nmcli connection down 'Wired connection 2'; nmcli connection up br0If SSH works on the bridge IP, cancel the at job and delete the old profile (nmcli connection delete 'Wired connection 2').
- VLAN on top of a bridge (VMs in VLAN 20): create the VLAN on
eth1(dev eth1 id 20) without an IP, and make it the port of a second bridgebr20. - Use it — KVM/libvirt VMs: network source "bridge br0". Containers can use it with a macvlan or bridge network.
- Check with
ip -d link show eth0.20(showsvlan id 20) andbridge link(showseth1 master br0).
Check that it worked
nmcli -f NAME,DEVICE,STATE connection show --active lists br0, br0-port1 and vlan20 as activated; ip -br addr shows 192.168.1.10/24 on br0 (not on eth1) and 10.20.0.15/24 on eth0.20; ping 10.20.0.1 works; after a reboot all is the same.
Common problems
| Problem | Cause | Fix |
|---|---|---|
| SSH lost while switching | IP moved off the old interface before the bridge came up. | Console, or the at safety net; do it in one command. |
| VLAN interface up but no traffic | Switch port not tagged for VLAN 20. | Ask for a trunk with VLAN 20 tagged. |
| Bridge has no IP after reboot | Old profile of eth1 still active and wins. | Delete the old profile; connection.autoconnect yes on br0. |
| VMs get no DHCP on the bridge | Wi-Fi port as bridge member, or the network blocks extra MAC addresses. | Use wired ports; allow MAC addresses on the switch / hypervisor. |
| Interface name too long | VLAN names over 15 characters. | Shorter ifname (for example vl20). |
| Firewall blocks bridged traffic | br_netfilter sends bridged packets through the firewall. | Allow it in the firewall, or set the bridge sysctls to 0 on pure VM hosts. |
Go further
- Command pages: nmcli, ip, at.
- Next how-tos: Set a static IP address, Add a network route, Run a command once at a set time, Load a kernel module at boot.
- Learn it: RHCSA — New connection profiles, RHCSA — Set IPv4, RHCSA — Profile files.
1Why does the bridge port lose its own IP address?
The port only carries traffic into the bridge; the bridge interface itself holds the address.
2What must the switch do for a VLAN interface to work?
The switch port must send that VLAN tagged (a trunk port).