Pcornel
Linux · Linux Networking

VLAN

Cheat sheet · https://pcornel.dk/topic.php?topic=2783

Back to the Topic

Answer

A Linux VLAN interface (e.g. eth0.20 or vlan20) tags traffic with an 802.1Q VLAN ID on a parent interface, so one physical port can carry several VLANs to a switch trunk.

Remember

The switch port must be a trunk that allows the VLAN; the parent interface must be up. Create persistently with nmcli (type vlan), netplan (vlans:) or a networkd .netdev. Untagged traffic stays on the parent.

First checks

  • ip -d link show <if> — link details incl. VLAN id
  • ip -br addr — interfaces and addresses
  • ip route — routing table and default route
  • ip neigh — ARP/neighbour cache
  • ip route get <dest> — route, interface and source chosen for a destination
  • nmcli device status / networkctl — which tool manages each interface

Commands

ip link add ... type vlan
tcpdump -e

Verify in this order

VLAN interface created on the parent → tags frames with the ID → switch trunk accepts the VLAN → replies tagged back → delivered to the VLAN interface

Where it usually breaks

First mismatch in link/interface → address/namespace → route/neighbor → firewall/policy → socket/daemon → DNS/TLS/SSH/application peer path; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2783

Confirmation

Confirm action

Continue?