A helpful lab on inter-VLAN routing using the router-on-a-stick method.

🧪 Networking Lab: Inter-VLAN Routing with Router-on-a-Stick
by: Anthony Gardés
Prerequisites:
- Cisco Packet Tracer
- A Computer
- Concepts: VLANs, 802.1Q trunking, router sub-interfaces, default gateways, subnetting basics, and basic Cisco CLI commands.
To get the most out of this lab, try completing each step without referring to the tips provided (the tips are incomplete answers intended to kickstart you if you get stuck). Repeat this lab until you can complete all the steps without needing to refer to any dropdown tips. The starter packet tracer file is provided below; the final will be included at the end of the post, in case you get stuck and need a reference. Happy labbing!
Step 1: Configure the PCs IP Settings
Each PC is assigned to a different VLAN and must be manually configured with:
- IP Address - This should be the second usable IP address in the subnet.
- Subnet Mask - Use the CIDR notation provided for the mask.
- Default Gateway - this should be the first IP address in the subnet.
This is what the settings would be for PC1 in VLAN 10.
IP: 192.168.10.2
Mask: 255.255.255.0
Gateway: 192.168.10.1
Step 2: VLANS and Access Ports
Create the VLANs and Access Ports on SW1.
This is how you'd configure VLAN 10 and interface fa0/1
Switch(config)# vlan 10
Switch(config)# interface fa0/1
Switch(config-if)# switchport mode
Switch(config-if)# switchport access
Step 3: Trunk Links
Configure the trunk link to the Router.
Switch(config)# interface g0/1
Switch(config-if)# switchport mode
switch(config-if)# switchport trunk
Step 4: Configure Sub-Interfaces
Since one physical interface will carry traffic for multiple VLANs, we will need to create sub-interfaces on the Router.
Router(config)# interface g0/0.10
Router(config-subif)# encapsulation dot1Q
Router(config-subif)# ip address 192.168.10.1 255.255.255.0
*Don't forget to enable the main interface!
Step 5: Test Inter-VLAN Connectivity
From PC1 in VLAN 10, try to ping PC2 in VLAN 20. If everything is configured correctly, you should see successful replies. If your pings are not successful, don't worry; this is a perfect time to start troubleshooting. Some ideas on troubleshooting are below. Also, below is the finished lab if you prefer to see the final working lab as a reference.
Pings failing between VLANs - Check default gateways on PCs
No ping to Router - Verify g0/0 is no shutdown
VLAN not working - check switchport mode = access
Router no routing - confirm sub-interface uses correct VLAN and IP
Trunk not forwarding VLAN Traffic - Verify switchport mode trunk
Give this lab a few tries until you can complete it from memory. Another great practice would be to make your own lab from scratch once you have this down. Creating my own labs after learning the material helped solidify everything much more effectively. I hope you enjoyed this one and found value in the exercise. I'm happy to provide more; feel free to shoot me an email anytime with ideas or concepts I might be able to help with.