LAB: VLAN, Trunk, Inter-VLAN Routing
Three lessons, one topology: this lab builds two switches and a router, creates VLANs 10 and 20, assigns access ports, joins the switches with an 802.1Q trunk, and finally makes the two VLANs talk through router-on-a-stick inter-VLAN routing. If you complete the checks at the end, you have just assembled the standard small-office switched network — and every command you type is exam-relevant.
- Create and name VLANs 10 and 20 on two switches.
- Assign access ports and confirm with show vlan brief.
- Configure an 802.1Q trunk between the switches.
- Configure router-on-a-stick subinterfaces for inter-VLAN routing.
- Verify with show interfaces trunk, show ip route, and ping.
- Troubleshoot VLAN/trunk/gateway problems using the normal symptom → cause → fix sequence.
Overview and goal
Two switches, S1 and S2, each host one PC. PC-A is in VLAN 10 (192.168.10.0/24) and PC-C is in VLAN 20 (192.168.20.0/24). The switches are linked by a trunk over which both VLANs ride, and router R1 terminates that trunk with subinterfaces to provide the default gateways. The goal has two parts:
- PC-A must not be reachable at Layer 2 from PC-C (they are in different VLANs).
- PC-A and PC-C must still be able to ping each other through R1 (inter-VLAN routing).
The whole lab is the “same-VLAN reachable, cross-VLAN routed” pattern in miniature.
Topology
Addressing plan
| Device | Interface | VLAN | IP address / prefix | Gateway |
|---|---|---|---|---|
| PC-A | NIC | 10 | 192.168.10.10 /24 | 192.168.10.1 |
| PC-C | NIC | 20 | 192.168.20.10 /24 | 192.168.20.1 |
| S1 | — | 10, 20 | — | — |
| S2 | — | 10, 20 | — | — |
| R1 | Gi0/0.10 | 10 | 192.168.10.1 /24 | — |
| R1 | Gi0/0.20 | 20 | 192.168.20.1 /24 | — |
Step 1 — Build the topology
In Packet Tracer (or GNS3/EVE-NG), place one router (R1, e.g. 4321), two switches, and two PCs. Cable as shown: PC-A to S1 Gi0/1, S1 Gi0/24 to S2 Gi0/24, S2 Gi0/2 to PC-C, and S1 Gi0/24 also to R1 Gi0/0 (— in Packet Tracer connect R1 Gi0/0 to switch port Gi0/24 or a spare like Gi0/23; the exact ports only need to match what you configure in the steps). Keep the hostname discipline from earlier labs: every device gets a name before its services.
Router> enable Router# configure terminal Router(config)# hostname R1 R1(config)# interface gigabitEthernet 0/0 R1(config-if)# no shutdown R1(config-if)# exit R1(config)# end Switch> enable Switch# configure terminal Switch(config)# hostname S1 S1(config)# end Switch# configure terminal Switch(config)# hostname S2 S2(config)# end
Step 2 — Configure host PCs
Give PC-A and PC-C their addresses and gateways from the table. In Packet Tracer the sequence is: click the PC → Desktop → IP Configuration, fill in IP, mask, and default gateway, and close.
PC-A → IP 192.168.10.10 mask 255.255.255.0 gateway 192.168.10.1 PC-C → IP 192.168.20.10 mask 255.255.255.0 gateway 192.168.20.1
Step 3 — Create the VLANs on S1
S1# configure terminal S1(config)# vlan 10 S1(config-vlan)# name Students S1(config-vlan)# exit S1(config)# vlan 20 S1(config-vlan)# name Staff S1(config-vlan)# exit
Lesson 13 revisited on hardware: the VLANs exist but carry nothing until ports join them.
Step 4 — Assign access ports on S1
S1(config)# interface gigabitEthernet 0/1 S1(config-if)# switchport mode access S1(config-if)# switchport access vlan 10 S1(config-if)# exit
PC-A’s port is now an access port in VLAN 10. Verify before moving on:
S1# show vlan brief VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Gi0/3, Gi0/4, Gi0/5, Gi0/6 10 Students active Gi0/1 20 Staff active
Step 5 — Configure S2
Repeat the VLAN creation on S2 (VLANs 10 and 20 with the same names), then put PC-C’s port into VLAN 20:
S2# configure terminal S2(config)# vlan 10 S2(config-vlan)# name Students S2(config-vlan)# exit S2(config)# vlan 20 S2(config-vlan)# name Staff S2(config-vlan)# exit S2(config)# interface gigabitEthernet 0/2 S2(config-if)# switchport mode access S2(config-if)# switchport access vlan 20 S2(config-if)# end
Step 6 — Build the trunk
Now connect the two switches with a trunk carrying both VLANs. Configure Gi0/24 on each switch. Setting the allowed list explicitly is good practice — it keeps future VLAN 30 from wandering onto this link by accident:
S1(config)# interface gigabitEthernet 0/24 S1(config-if)# switchport mode trunk S1(config-if)# switchport trunk allowed vlan 10,20 S1(config-if)# end S2(config)# interface gigabitEthernet 0/24 S2(config-if)# switchport mode trunk S2(config-if)# switchport trunk allowed vlan 10,20 S2(config-if)# end S1# show interfaces trunk Port Mode Encapsulation Status Native vlan Gi0/24 on 802.1q trunking 1 Port Vlans allowed on trunk Gi0/24 10,20
Step 7 — Set up router-on-a-stick on R1
The router terminates the trunk from S1. Split Gi0/0 into two subinterfaces — one per VLAN — and give each its gateway address. The physical interface must be up (we enabled it in Step 1), and its IP address lives on the subinterfaces, never on Gi0/0 itself:
R1(config)# interface gigabitEthernet 0/0.10 R1(config-subif)# encapsulation dot1q 10 R1(config-subif)# ip address 192.168.10.1 255.255.255.0 R1(config-subif)# exit R1(config)# interface gigabitEthernet 0/0.20 R1(config-subif)# encapsulation dot1q 20 R1(config-subif)# ip address 192.168.20.1 255.255.255.0 R1(config-subif)# end
If your trunk also used a non-default native VLAN, one subinterface would need the
encapsulation dot1q <id> native form — not required here since the native
VLAN is 1 and no subinterface claims it.
Step 8 — Verify: show commands and pings
Run the verification chain in order. Each check reflects one lesson:
S1# show vlan brief ! Lesson 13: ports in the right VLANs S1# show interfaces trunk ! Lesson 14: trunk up, allowed list correct R1# show ip interface brief ! Lesson 15: both subinterfaces up R1# show ip route ! connected 192.168.10.0/24 and 192.168.20.0/24
Then the functional tests, from the hosts:
C:\> ping 192.168.20.10 Reply from 192.168.20.10: bytes=32 time=1ms TTL=127 Reply from 192.168.20.10: bytes=32 time=1ms TTL=127
When PC-A pings PC-C, the packet rides VLAN 10 to the trunk, reaches R1 on subinterface .10, is routed out subinterface .20, and is re-encapsulated into a VLAN 20 frame at S2 for PC-C. Two good negative tests complete the picture:
- PC-A to PC-C before Step 7 would fail (no gateway in each VLAN yet).
- PC-A to the VLAN 20 device at Layer 2 never works, because the VLANs and their broadcast domains are separate by design.
Step 9 — Troubleshooting guide
| Symptom | Likely cause | Fix |
|---|---|---|
| PC-A ping fails but S1↔S1 trunk is up | Port never assigned to VLAN (still VLAN 1) | switchport mode access + switchport access vlan 10, re-check show vlan brief |
| Trunk shows but allowed list misses a VLAN | Allowed list pruned too far | switchport trunk allowed vlan 10,20 on both ends |
| Subinterfaces up, hosts in same VLAN can’t ping each other across switches | VLAN missing on the other switch or trunk not carrying it | Create VLAN on both switches; verify show interfaces trunk |
| Host can’t reach its own gateway | Wrong default gateway on the host | PC-A must use 192.168.10.1 (VLAN 10), PC-C must use 192.168.20.1 |
| Router receives nothing on .10 | Physical Gi0/0 shut down, or encapsulation/subinterface mismatch | no shutdown on Gi0/0; confirm encapsulation dot1q numbers match the VLANs |
show vlan brief),
trunk health (show interfaces trunk), subinterfaces (show ip
interface brief), then routing (show ip route). Hosts and gateways are
always last, because they are the most obvious and the least often wrong.
The vocabulary you need
Every term below appears in the lesson text above. Select one to read its definition, then use the quiz at the end to check what stuck.
Review
Check what you have learned with these review questions.
Sources & references
- Cisco. CCNA (200-301) Exam Topics. cisco.com.
- IETF. Request for Comments (RFCs). rfc-editor.org.
- IANA. Internet Assigned Numbers Authority registries. iana.org.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.