VLANs, Trunks and Inter-VLAN Routing: The Full CCNA Picture
VLANs split one switch into many virtual LANs — but that separation is absolute: VLANs can't talk to each other without a Layer 3 device. This guide connects the whole story: why VLANs exist, how trunks carry them with 802.1Q tags, and the two ways to route between them — router-on-a-stick and the multilayer-switch SVI method — with full configurations and the exam traps Cisco loves.
Why VLANs exist
Without VLANs, a switch is one flat broadcast domain: every broadcast frame (ARP, DHCP) is flooded to every port. In a real network that's a security and performance problem — the HR department's traffic is visible to the guest Wi-Fi, and one misbehaving device's broadcasts hit everyone.
A VLAN (Virtual LAN) logically divides one physical switch into multiple virtual switches. Each VLAN is its own broadcast domain: broadcasts stay inside the VLAN, and a Layer 2 switch will never forward a frame from one VLAN to another. VLANs give you segmentation without buying a switch per department.
- Security — sensitive departments are isolated from guests and IoT devices.
- Broadcast control — smaller broadcast domains mean less flooding.
- Flexibility — move a user to a different VLAN by changing a port config, not by rewiring.
Three facts the exam drills constantly: VLAN IDs 1–4094 are usable (1 is the default, 1002–1005 are reserved legacy Token Ring/FDDI), VLAN 1 cannot be deleted, and the normal range is 1–1005 while 1006–4094 is the extended range (stored in the running config, not vlan.dat, and requiring VTP transparent mode on older switches).
Creating VLANs and assigning access ports
Our running example uses three VLANs on a small office switch. If you haven't configured VLANs before, our VLANs and trunking guide covers the groundwork — here is the essential config:
! Create the VLANs
vlan 10
name Sales
vlan 20
name HR
vlan 30
name Guests
! Assign ports 1-8 to the Sales VLAN as access ports
interface range FastEthernet0/1 - 8
switchport mode access
switchport access vlan 10
Verify with show vlan brief and show interfaces status. A port in access mode belongs to exactly one VLAN, and frames leave it untagged — PCs and printers have no idea VLANs exist.
Access ports vs trunk ports
This distinction is the foundation of everything that follows, and the exam tests it in nearly every switching scenario:
| Access port | Trunk port | |
|---|---|---|
| Carries | Exactly one VLAN | Multiple VLANs over one link |
| Connects to | End devices (PC, printer, phone) | Switches, routers, firewalls |
| Tagging | Frames sent untagged | Frames tagged with 802.1Q (except native VLAN) |
| Typical config | switchport mode access | switchport mode trunk |
When you have several switches, you don't run one cable per VLAN between them — you run one trunk that carries all VLANs. That's where tagging comes in.
802.1Q tagging and the native VLAN
IEEE 802.1Q is the open-standard trunking protocol the CCNA expects (Cisco's old proprietary ISL is long dead — if you see ISL as an answer choice, it's a distractor). When a frame enters a trunk port, the switch inserts a 4-byte tag into the Ethernet header, between the source MAC and the EtherType field. The tag carries a 12-bit VLAN ID, so the switch at the far end knows exactly which VLAN the frame belongs to. When the frame exits onto an access port, the tag is stripped — end devices never see it.
One VLAN is special: the native VLAN. Its traffic crosses the trunk untagged. On Cisco switches the native VLAN defaults to VLAN 1, and both ends of a trunk must agree on it. Configure the trunk like this:
! Trunk to the router (Gi0/1)
interface GigabitEthernet0/1
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk native vlan 99
switchport trunk allowed vlan 10,20,30,99
Two commands in there deserve attention. switchport trunk native vlan 99 moves untagged traffic off VLAN 1 — a security best practice, since VLAN 1 carries control traffic (CDP, STP BPDUs) and attackers target it. switchport trunk allowed vlan prunes the trunk to only the VLANs that need to cross it, which the exam frequently asks about: if a VLAN isn't in the allowed list, its traffic is dropped on that trunk, no matter how correct everything else is.
For the Layer 2 foundation underneath all of this — MAC learning, flooding, and how switches forward — see our switching fundamentals guide.
Why you still need inter-VLAN routing
Here's the catch the exam wants you to internalise: VLANs are completely isolated at Layer 2. A PC in VLAN 10 (192.168.10.5) cannot reach a server in VLAN 20 (192.168.20.5) — even with perfect IP addressing — because the switch will never forward a frame between VLANs. Traffic between VLANs must go up to Layer 3 and be routed.
Each VLAN gets its own IP subnet, and hosts in that VLAN use the router's address in their subnet as their default gateway. In our example: VLAN 10 uses 192.168.10.0/24 with gateway 192.168.10.1, VLAN 20 uses 192.168.20.0/24 with gateway 192.168.20.1, VLAN 30 uses 192.168.30.0/24 with gateway 192.168.30.1. There are two standard ways to provide that routing.
Method 1: router-on-a-stick
Router-on-a-stick connects a router to the switch with a single trunk cable — the "stick". The router's physical interface is split into logical subinterfaces, one per VLAN, and each subinterface acts as that VLAN's gateway.
The key rules: the physical interface gets no IP address (it must still be brought up with no shutdown), each subinterface needs encapsulation dot1Q <vlan-id> before its ip address command, and the subinterface number conventionally matches the VLAN ID (Gi0/0.10 for VLAN 10) — though any number technically works.
Full configuration
! ---------- SWITCH SIDE ----------
! VLANs already created (see above); access ports assigned.
! Trunk facing the router:
interface GigabitEthernet0/1
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk native vlan 99
switchport trunk allowed vlan 10,20,30,99
! Native VLAN 99 must exist:
vlan 99
name NativeUnused
! ---------- ROUTER SIDE ----------
! Physical interface: no IP address, but must be up
interface GigabitEthernet0/0
no ip address
no shutdown
! Subinterface for VLAN 10 (Sales) - gateway 192.168.10.1
interface GigabitEthernet0/0.10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0
! Subinterface for VLAN 20 (HR) - gateway 192.168.20.1
interface GigabitEthernet0/0.20
encapsulation dot1Q 20
ip address 192.168.20.1 255.255.255.0
! Subinterface for VLAN 30 (Guests) - gateway 192.168.30.1
interface GigabitEthernet0/0.30
encapsulation dot1Q 30
ip address 192.168.30.1 255.255.255.0
That's it — no routing protocol needed. The three subnets are directly connected on the router, so it routes between them automatically. A packet from a Sales PC to an HR PC travels: access port (VLAN 10) → tagged across the trunk → router subinterface Gi0/0.10 → routed to Gi0/0.20 → tagged back down the trunk → access port (VLAN 20).
The trade-off: every inter-VLAN packet crosses the same physical link twice (up and back down the stick), so one busy trunk becomes the bottleneck, and the router is a single point of failure. Verify with show ip interface brief and show vlans on the router, and show interfaces trunk on the switch.
Method 2: SVI on a multilayer switch
The modern approach: a multilayer switch routes between VLANs itself, in hardware, with no router and no extra cable. Each VLAN gets a SVI (Switched Virtual Interface) — a virtual Layer 3 interface named Vlan10, Vlan20, and so on — carrying that VLAN's gateway address.
! Enable Layer 3 routing on the switch (off by default!)
ip routing
! One SVI per VLAN, each the gateway for its subnet
interface Vlan10
ip address 192.168.10.1 255.255.255.0
no shutdown
interface Vlan20
ip address 192.168.20.1 255.255.255.0
no shutdown
interface Vlan30
ip address 192.168.30.1 255.255.255.0
no shutdown
The exam's favourite gotcha here: ip routing is disabled by default on a multilayer switch. Without it, the SVIs come up but no routing happens between them — a textbook "everything looks configured but nothing works" troubleshooting question. Note also that an SVI only comes up (line protocol up) if the VLAN exists and at least one access port or trunk carrying that VLAN is up — otherwise the gateway address is unreachable.
The CCNA treats the multilayer switch as the best-practice answer: faster (hardware switching), simpler (no trunk to a router), and it scales. Router-on-a-stick survives in the exam as the budget option and as a configuration drill. Multilayer switches also run routing protocols between SVIs, which ties into the routing topics in our routing fundamentals guide.
Exam traps: the questions Cisco loves
Trap 1 — Native VLAN mismatch
One end of a trunk has native VLAN 1, the other has native VLAN 99. Untagged frames get dumped into the wrong VLAN — traffic blackholes or leaks between VLANs, and the switches log %CDP-4-NATIVE_VLAN_MISMATCH. Fix: make both ends match with switchport trunk native vlan. If an exam exhibit shows that log message, the answer is native VLAN mismatch — full stop.
Trap 2 — Trunk allowed VLANs
show interfaces trunk shows which VLANs are actually forwarded. A VLAN missing from the allowed list is silently dropped on that trunk. Classic scenario: a new VLAN works on one switch but is unreachable across the trunk — check the allowed list before anything else.
Trap 3 — encapsulation before IP address
On a router subinterface, encapsulation dot1Q 10 must be entered before the ip address — IOS rejects it the other way round. If a config snippet shows the IP address first, that's your error.
Trap 4 — DTP and trunk negotiation
Two switches with default switchport mode dynamic auto on both ends will not form a trunk (auto/auto = access). The exam-safe config is switchport mode trunk statically on both ends, or dynamic desirable on at least one side. And remember: the physical router interface in router-on-a-stick needs no shutdown — subinterfaces inherit the physical interface's state.
VLANs interact with spanning tree too — each VLAN runs its own STP instance (PVST+), which is why root bridge placement per VLAN matters. Our STP root bridge and port roles guide covers that side of the story.
Quick-fire practice questions
Five exam-style questions covering this guide's core. Answer from memory, then click to reveal.
Q1. A router-on-a-stick subinterface Gi0/0.20 has an IP address configured but hosts in VLAN 20 can't reach other VLANs. The config shows no encapsulation dot1Q line. What's wrong?
The subinterface doesn't know which VLAN's tagged traffic to process. Without encapsulation dot1Q 20, the router can't match incoming 802.1Q tags to the subinterface, so it drops the frames. Add the encapsulation command (before the IP address), and routing starts working. Also check the trunk's allowed VLAN list on the switch.
Q2. Both switches log %CDP-4-NATIVE_VLAN_MISMATCH on their trunk link. Users report intermittent connectivity issues. What's the cause and the fix?
Native VLAN mismatch. One end of the trunk is configured with a different native VLAN than the other, so untagged traffic is placed into the wrong VLAN. Fix: configure the same native VLAN on both ends with switchport trunk native vlan <id> and verify with show interfaces trunk.
Q3. A new VLAN 40 works fine on Switch A but hosts in VLAN 40 on Switch B can't reach it. The trunk between them is up. What's the most likely cause?
VLAN 40 is missing from the trunk's allowed VLAN list. Run show interfaces trunk on both switches and check the "Vlans in spanning tree forwarding state" / allowed list. Add it with switchport trunk allowed vlan add 40. Also confirm VLAN 40 actually exists on Switch B (show vlan brief).
Q4. A multilayer switch has SVIs configured with IP addresses for VLANs 10 and 20, but the VLANs can't route between each other. What's missing?
ip routing is not enabled. Layer 3 routing is disabled by default on multilayer switches — the SVIs will be up, but no routing occurs between them. Enter ip routing in global config mode. (Second check: each SVI needs its VLAN to exist and have at least one up port/trunk, or its line protocol stays down.)
Q5. Which statement about router-on-a-stick is TRUE?
C) Each subinterface requires its own encapsulation dot1Q statement matching its VLAN, and the physical interface needs no IP address. Distractors to reject: A) "the physical interface holds the gateway addresses" — no, the subinterfaces do; B) "it needs one cable per VLAN" — no, that's the legacy method, one trunk carries all VLANs; D) "it routes in hardware faster than a multilayer switch" — backwards, the multilayer switch is the faster option.
Inter-VLAN routing on the CCNA 200-301
VLANs, trunking and inter-VLAN routing sit in the Network Fundamentals and IP Connectivity domains, and they appear in both configuration and troubleshooting questions. The exam expects you to configure a trunk, spot a native VLAN mismatch from a log, pick the right inter-VLAN routing method for a scenario, and know why ip routing matters on a multilayer switch. Drill the config commands on flashcards until the subinterface sequence is automatic, then test yourself against full exam scenarios with our CCNA 200-301 practice questions.
Keep studying: VLANs & Trunking Switching Fundamentals STP Root Bridge & Port Roles Flashcards Practice Questions
Ready to test yourself?
VLANs and inter-VLAN routing are core CCNA 200-301 topics. Take the free 25-question mock test — no sign-up — and find out where you stand. One subscription (£5/month or £39/year) unlocks all 370 exam-style questions, 20 in-browser labs and 300 flashcards across all 10 certifications.
Start the free mock test →