Skip to main content
RunBook Academy

VyOSVIII · VLANsVLAN

Trunks and access — what the operator controls at each end of the cable

Foundation⏱ ~12 minset interfaces ethernet eth0 vifshow interface ethernettcpdump -e -n vlan

What you'll learn

  • Configure a VyOS interface as an access port for a single VLAN
  • Configure a VyOS interface as a trunk port for multiple VLANs
  • Match the VyOS configuration to the switch configuration
  • Recognise the trunk/access mismatch failure modes

Prerequisites

Verified against VyOS 1.5.x LTS (circinus) · VyOS 1.4.x (sagitta) — legacy · FRRouting 10.x (VyOS 1.5) · Linux kernel 6.6 LTS (VyOS 1.5 base) · strongSwan 5.9.x (IPsec) · WireGuard 1.0.x (kernel module + userspace tooling) · 2026-08-15

Not yet marked complete on this device.

Trunks and access — what the operator controls at each end of the cable

The operator’s VyOS box has two roles on a VLAN link: as an access port (carrying traffic for one VLAN, untagged) or as a trunk port (carrying traffic for multiple VLANs, tagged). The configuration must match the switch port on the other end.

Access port on VyOS

[edit]
vyos@vyos# set interfaces ethernet eth0 vif 10 address '192.0.2.1/24'
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# save

The interface has one sub-interface (VLAN 10). The parent eth0 carries untagged frames that the kernel treats as VLAN 10. This is the access port pattern from the operator’s side.

Trunk port on VyOS

[edit]
vyos@vyos# set interfaces ethernet eth0 vif 10 address '192.0.2.1/24'
[edit]
vyos@vyos# set interfaces ethernet eth0 vif 20 address '203.0.113.1/24'
[edit]
vyos@vyos# set interfaces ethernet eth0 vif 30 address '198.51.100.1/24'
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# save

The interface has multiple sub-interfaces. The parent eth0 carries all three VLANs as tagged frames. The switch on the other end must be configured as a trunk port with the same VLANs.

Native VLAN on the parent

[edit]
vyos@vyos# set interfaces ethernet eth0 native-vlan '999'
[edit]
vyos@vyos# commit
[edit]
vyos@vyos# save

The native VLAN is the VLAN for untagged frames on the parent. Setting it to an unused value (999 is a common convention) mitigates VLAN-hopping attacks.

Matching the switch

VyOSSwitchNotes
vif 10Trunk port, allowed VLAN 10Tagged frames on VLAN 10
vif 20Trunk port, allowed VLAN 20Tagged frames on VLAN 20
native-vlan 999Trunk port, native VLAN 999Untagged frames in VLAN 999
No vifAccess port, PVID 10Untagged frames in VLAN 10

The operator must ensure the VyOS and switch configurations match. A mismatch produces frames in the wrong VLAN.

How the result is validated

show interface ethernet
ip link show
tcpdump -i eth0 -e -n vlan <id>

The first shows the VyOS view; the second shows the kernel mapping; the third captures only specific VLAN frames.

How it fails

The production failure modes the engineer must recognise:

  • VyOS trunk, switch access. The switch sends untagged frames. The VyOS kernel places them in the native VLAN; if no native VLAN is configured, the frames are dropped.
  • VyOS access, switch trunk. The switch sends tagged frames. The VyOS kernel drops them because the access interface does not have a sub-interface for the tagged VLAN.
  • Allowed VLAN mismatch. The switch’s trunk allows VLAN 10, 20, 30 but VyOS only has sub-interfaces for 10, 20. Frames for VLAN 30 are dropped at the switch.
  • Native VLAN mismatch. VyOS native VLAN 999, switch native VLAN 1. Untagged frames are placed in different VLANs at each end.

Rollback

The recovery from a trunk/access mismatch:

  • Configure both ends as the same type (both trunk, both access).
  • Match allowed VLANs and native VLAN.
  • Verify with tcpdump -e -n vlan <id>.

Production discipline

Cross-course references

The Proxmox course’s XXIX-Proxmox-Networking covers the host-side trunk configuration. The OPNsense course’s XIV-OPNsense-VLAN covers the equivalent configuration on the firewall side. The Linux course’s XIX-Linux-NetFoundations covers the kernel’s VLAN model.

Quiz

Knowledge check · 4 questions

  1. Q1. Which configuration makes `eth0` a trunk port for VLANs 10 and 20?

  2. Q2. VyOS is typically configured as an access port in production deployments.

  3. Q3. VyOS is configured as a trunk with VLANs 10 and 20. The switch is configured as an access port for VLAN 10. What happens to VLAN 20 traffic?

    The switch's access port only forwards VLAN 10 traffic. Frames for VLAN 20 are dropped at the switch port.

  4. Q4. VyOS native VLAN 999, switch native VLAN 1. Untagged frames take different paths at each end. What is the recovery?

    The switch sends untagged frames in VLAN 1. VyOS receives them and places them in VLAN 999 (the native VLAN). The frames are now in different VLANs at each end.

Passing score: 75%. Answers are checked in this browser.