Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 3 of 6 · Concept · 20 min · revision 1

VLANs and trunks: tagging, the native VLAN and inter-VLAN routing

Separate broadcast domains across switches with IEEE 802.1Q VLAN tags, distinguish access ports, voice VLANs, trunk ports and native VLANs, design router-on-a-stick vs Layer 3 SVIs and diagnose VLAN or native-VLAN mismatches.

Contentsand lesson path

What you will learn

  • Configure access and 802.1Q trunk ports and route between VLANs with a router-on-a-stick or layer-3 interfaces.

01. Why it matters

Suppose an office grows from 15 machines into three departments—Engineering, Finance, and Guest Wi-Fi—spread across four floors. Buying physically separate switches and running three separate riser cables per floor triples hardware and cabling costs while leaving half the ports idle, yet plugging everyone into one flat bridge lets guest laptops sniff Finance broadcasts and reach Finance servers directly at Layer 2.

Virtual LANs (VLANs) under IEEE 802.1Q solve both problems together: a single switch hosts multiple isolated Layer 2 broadcast domains, and a single uplink cable (trunk) multiplexes all of them between switches and routers.

02. Access ports, voice VLANs, 802.1Q trunks and the native VLAN

Why not run one dedicated patch cable per VLAN between two switches? For two VLANs in the same rack that works, but across 20 VLANs and 10 closets it burns 200 uplink ports. Instead, 802.1Q defines distinct port roles:

  • Access port (untagged): Connects an endpoint (workstation, printer, server NIC) that transmits plain Ethernet frames. The port's PVID (Port VLAN ID) places every untagged ingress frame into that single VLAN (for instance, VLAN 20) and strips the tag before transmitting frames to the endpoint.
  • Voice VLAN (access + tagged voice): Desk IP phones often sit inline between the wall jack and the user's PC. The switch configures one untagged data VLAN (PVID, say VLAN 10 for the PC) plus one tagged Voice VLAN (say VLAN 50), signalled via LLDP-MED or CDP: the phone tags its own VoIP frames with VLAN 50 while bridging the PC's untagged frames straight into VLAN 10.
  • Trunk port (tagged): Links switches together or connects a switch to a router or hypervisor. When a frame from VLAN 20 leaves over a trunk whose native VLAN is 1, the switch inserts a 4-byte 802.1Q header right after the source MAC: 2-byte Tag Protocol Identifier (TPID 0x8100) plus 2-byte Tag Control Information containing 3 priority bits (PCP), 1 drop-eligible bit (DEI), and a 12-bit VLAN ID (1–4094; 0 marks priority-tagged frames without a VLAN ID and 4095 is reserved). The receiving switch reads 20, keeps the frame isolated to VLAN 20, and strips the tag when delivering out an access port.

Native VLAN rules, mismatches, and double-tagging: Every trunk designates one VLAN (default 1 on most switches) as its native VLAN, whose frames cross untagged. Any untagged frame arriving on the trunk enters the receiving port's native VLAN. If Switch A uses native VLAN 1 while Switch B uses native VLAN 99 on the same trunk, tagged VLANs (10, 20) continue working, but untagged VLAN 1 frames from A drop straight into VLAN 99 on B—silently bridging two segments together! Worse, if user access ports also sit in default VLAN 1 while the trunk's native VLAN is 1, an attacker can craft a double-tagged frame (outer=1, inner=20): the first switch strips outer native tag 1 on trunk egress, exposing the spoofed inner tag 20 to the downstream switch. Best practice moves the trunk native VLAN to an unused parking VLAN on both ends (or tags native frames where supported), moves user ports off VLAN 1, and prunes the trunk's allowed VLAN list.

Text · Standard Ethernet II frame vs 802.1Q tagged frame on a trunk
Access link: [Dst MAC 6B][Src MAC 6B][EtherType 2B][Payload ..........][FCS 4B]
802.1Q trunk:[Dst MAC 6B][Src MAC 6B][0x8100|TCI:VID=20][EtherType 2B][Pay][FCS]
                                      |<---- 4 bytes ---->|

03. Inter-VLAN routing: router-on-a-stick vs Layer 3 SVIs

Isolating VLAN 10 (192.0.2.0/24) and VLAN 20 (198.51.100.0/24) at Layer 2 means hosts cannot ARP for each other across VLANs; a Layer 3 router must forward packets between subnets. Choose between two designs:

  1. Router-on-a-stick (ROAS): One physical trunk links the switch to a router (eth0). On Linux (ArchWiki VLAN and ip-link(8)), you create one VLAN subinterface per segment (ip link add link eth0 name eth0.10 type vlan id 10 and eth0.20) and assign 192.0.2.1/24 to eth0.10 and 198.51.100.1/24 to eth0.20. The kernel reads the incoming 0x8100 header on eth0 and demultiplexes tagged frames to the matching subinterface (while an address placed directly on bare eth0 receives only untagged native frames), automatically installing directly connected kernel routes for each subnet. When not to use ROAS: On a full-duplex 1 Gb/s trunk, switch-to-router (VLAN 10) and router-to-switch (VLAN 20) travel in opposite wire directions, so a single one-way 900 Mb/s transfer still fits. However, because every inter-VLAN packet uses both directions of that single cable, the trunk caps the combined sum of bidirectional inter-VLAN traffic at roughly 1 Gb/s per direction (alongside router CPU forwarding capacity). When VLAN 10 pushes 600 Mb/s to VLAN 20 while VLAN 20 simultaneously pushes 600 Mb/s back (1.2 Gb/s demand in each direction), the shared trunk saturates and throttles both streams.
  2. Layer 3 Switch Virtual Interfaces (SVIs): A Layer 3 switch terminates vlan10 and vlan20 gateways inside its own switching ASIC and routes between them at wire speed without hairpinning out an external cable—the standard choice for campus cores and busy server racks.

Diagnosing a missing allowed VLAN: If VLAN 10 hosts reach external networks through a router-on-a-stick while VLAN 20 hosts cannot ping 198.51.100.1 even though eth0.20 is UP, inspect the switch trunk's allowed VLAN list: omitting VLAN 20 from the trunk drops VLAN 20 frames before they ever reach the router while leaving VLAN 10 untouched. Always confirm both ends of any trunk allow the exact same VLAN IDs.

04. Check your understanding

Practice check · 3 questions

Voice VLANs, native-VLAN hygiene and inter-VLAN bottlenecks

Apply 802.1Q tagging rules and routing architectures to each scenario.

Q1. A desk IP phone plugs into switch port Gi1/0/5, and a PC plugs into the phone's pass-through port. The switch port uses data VLAN 10 (PVID, untagged) and Voice VLAN 50 (tagged). How do frames from the PC and phone leave toward the switch?
Q2. Server A (VLAN 10) pushes 600 Mb/s to Server B (VLAN 20) while Server B simultaneously pushes 600 Mb/s back to Server A through a router-on-a-stick over one 1 Gb/s full-duplex trunk. Router CPU stays below 25%, yet each stream stalls near 500 Mb/s. Why?
Q3. Why should you move a trunk's native VLAN away from VLAN 1 onto an unused parking VLAN when user access ports also sit in VLAN 1 by default?
Practice only: not graded, not saved, not evidence.

05. Apply it

Plan a migration from a 1 Gb/s router-on-a-stick serving VLANs 10, 20, 30, and 40 on eth0 to a Layer 3 switch using SVIs: explain where default gateways move, why concurrent bidirectional inter-VLAN transfers bottlenecked on the single ROAS trunk can run at full line rate inside the switching ASIC, and what happens if one switch-to-switch trunk omits VLAN 30 from its allowed list.

Next, configure a live vlan_filtering 1 Linux bridge, 802.1Q trunk, and router-on-a-stick in the VLAN trunking lab.

06. Review prompt

Explain how an untagged PC frame and a tagged IP-phone frame share one switch port, why matching an access VLAN with a trunk native VLAN enables double-tagging, and when Layer 3 SVIs beat router-on-a-stick.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check