What are we trying to make work?
PC1 and PC3 are employees in VLAN 10 on different switches. Their frames should cross the inter-switch trunk without passing through a router. PC2 is in VLAN 20, a separate Ethernet group and IP subnet. PC1 needs gateway R1 to reach it. We deliberately permit that routed lab test; a production guest policy may deny it.
A VLAN separates local Ethernet forwarding. A trunk carries multiple VLANs on one link. Router-on-a-stick places several logical router subinterfaces on one physical trunk. Each data subinterface supplies its VLAN's default gateway, the local router address used for remote destinations.
Test the switched path before the routed path. A failure between VLANs is easier to investigate after you have proved the required local links.
Lab equipment and starting state
Build a small two-floor office with router-on-a-stick. Use a router that supports 802.1Q subinterfaces and two switches with 802.1Q trunk support. Interface names vary by model. Start with console access and set the PCs to the static addresses below. Commands and output are documentation-based examples, not lab captures.
The commands use Cisco Catalyst IOS or IOS XE-style Layer 2 switchports and an IOS-style router. Use an isolated emulator, simulator or spare lab devices with the required feature support. Simulator command coverage varies. Begin with the named interfaces free of conflicting configurations, their cables connected and links enabled. Do not erase or repurpose an operational network to reproduce this lab.
Device key: R1 (router) · SW1, SW2 (switch) · PC1, PC3 (computer) · PC2 (laptop)
Lines show the example’s network connections. Thick links: uplinks/WAN, as labelled. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.
Reading the addresses
IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.
An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.
- PC1: IP 192.168.10.11
- PC2: IP 192.168.20.11
- PC3: IP 192.168.10.12
- 1. Test 1: same VLAN, two switches. PC1 → PC3 crosses the SW1–SW2 trunk. No router needed.
- 2. Test 2: between VLANs. PC1 → PC2 goes up to R1 and back down, tagged VLAN 10 then VLAN 20.
| Device | Interface | VLAN | IP address | Gateway |
|---|---|---|---|---|
| R1 | Gi0/0.10 | 10 | 192.168.10.1/24 | – |
| R1 | Gi0/0.20 | 20 | 192.168.20.1/24 | – |
| PC1 | SW1 Gi1/0/1 | 10 | 192.168.10.11/24 | 192.168.10.1 |
| PC2 | SW1 Gi1/0/3 | 20 | 192.168.20.11/24 | 192.168.20.1 |
| PC3 | SW2 Gi1/0/1 | 10 | 192.168.10.12/24 | 192.168.10.1 |
| Trunks | R1–SW1, SW1–SW2 | 10, 20, native 99 | – | – |
Every /24 host uses mask 255.255.255.0. PC1 and PC3 share network 192.168.10.0/24; PC2 is in 192.168.20.0/24. The VLAN IDs 10 and 20 are switch classifications, not values calculated from those IP addresses. The table pairs one subnet with each VLAN as a design choice.
Create the VLANs, then assign the ports
Reach global configuration mode with configure terminal from the privileged prompt. vlan 10 creates or selects a VLAN; name supplies a label. switchport mode access fixes an endpoint port's role, and switchport access vlan 10 assigns ordinary untagged data to VLAN 10.
SW1 · global configuration mode
vlan 10
name EMPLOYEES
vlan 20
name GUESTS
vlan 99
name NATIVE
interface GigabitEthernet1/0/1
switchport mode access
switchport access vlan 10
interface GigabitEthernet1/0/3
switchport mode access
switchport access vlan 20
interface range GigabitEthernet1/0/23 - 24
switchport mode trunk
switchport trunk allowed vlan 10,20,99
switchport trunk native vlan 99
switchport nonegotiateSW2 · global configuration mode
vlan 10
name EMPLOYEES
vlan 20
name GUESTS
vlan 99
name NATIVE
interface GigabitEthernet1/0/1
switchport mode access
switchport access vlan 10
interface GigabitEthernet1/0/24
switchport mode trunk
switchport trunk allowed vlan 10,20,99
switchport trunk native vlan 99
switchport nonegotiateSW2 uses Gi1/0/24 toward SW1. It has no router-facing trunk in this topology.
Give R1 a gateway for each data VLAN
Use the router-on-a-stick configuration from Design 1 in Routing between VLANs.
interface GigabitEthernet0/0
no ip address
no shutdown
interface GigabitEthernet0/0.10
encapsulation dot1Q 10
ip address 192.168.10.1 255.255.255.0
interface GigabitEthernet0/0.20
encapsulation dot1Q 20
ip address 192.168.20.1 255.255.255.0
interface GigabitEthernet0/0.99
encapsulation dot1Q 99 nativeR1, global configuration mode, on the isolated lab interface. Data gateways belong to .10 and .20; .99 matches the unused untagged-native VLAN and has no host gateway address.
The encapsulation dot1Q value binds a subinterface to a VLAN. The suffix .10 is a helpful name; the encapsulation value is the actual binding. R1 learns both subnets as directly connected when the interfaces are operational, so no static route between VLANs 10 and 20 is needed.
| Command | What it does |
|---|---|
vlan 10 / name | Creates the VLAN in the switch's database and labels it |
switchport mode access | Fixes the port as access rather than negotiating a trunk; changing the configuration can change the role |
switchport access vlan 10 | Puts the port's device into VLAN 10 |
switchport mode trunk | Makes the port a permanent 802.1Q trunk |
switchport trunk allowed vlan | Limits the trunk to the VLANs listed |
switchport trunk native vlan 99 | Moves untagged trunk traffic to unused VLAN 99, on both ends |
Some older platforms also need switchport trunk encapsulation dot1q before switchport mode trunk.
Learn more: Lab: Inter-VLAN Routing
What the working lab shows
SW1#show vlan brief VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Gi1/0/2, Gi1/0/4, Gi1/0/5, ... 10 EMPLOYEES active Gi1/0/1 20 GUESTS active Gi1/0/3 99 NATIVE active 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup
SW1#show interfaces trunk Port Mode Encapsulation Status Native vlan Gi1/0/23 on 802.1q trunking 99 Gi1/0/24 on 802.1q trunking 99 Port Vlans allowed on trunk Gi1/0/23 10,20,99 Gi1/0/24 10,20,99 Port Vlans allowed and active in management domain Gi1/0/23 10,20,99 Gi1/0/24 10,20,99 Port Vlans in spanning tree forwarding state and not pruned Gi1/0/23 10,20,99 Gi1/0/24 10,20,99
R1#show ip interface brief Interface IP-Address OK? Method Status Protocol GigabitEthernet0/0 unassigned YES unset up up GigabitEthernet0/0.10 192.168.10.1 YES manual up up GigabitEthernet0/0.20 192.168.20.1 YES manual up up GigabitEthernet0/0.99 unassigned YES unset up up
show ip route connectedOn R1: both 192.168.10.0/24 and 192.168.20.0/24 should appear as connected networks.
PC1> ping 192.168.20.11 Reply from 192.168.20.11: bytes=32 time=1ms TTL=127 Reply from 192.168.20.11: bytes=32 time=1ms TTL=127
A working ping proves connectivity, not that the design is secure. If guests shouldn't reach employees, also test that the prohibited paths are blocked once your ACLs or firewall rules are in place.
ARP (Address Resolution Protocol) finds a local receiver's MAC address. PC1 resolves PC3 directly for the same-subnet test. For PC2, PC1 resolves R1's VLAN 10 gateway instead. The IP destination remains PC2; R1 builds a new frame in VLAN 20. PC2's reply requires its own correct gateway, 192.168.20.1.
Finish and verify
- Ping each PC's own gateway, then PC1 → PC3 across the switch trunk, then PC1 → PC2 through R1.
- On isolated SW1 Gi1/0/23, use
switchport trunk allowed vlan remove 10. Confirm that PC1 → PC3 fails while PC1 → PC2 can still work. The two tests use different SW1 uplinks. - Restore that same interface with
switchport trunk allowed vlan add 10. The add form retains VLANs 20 and 99. Verify the trunk lists on both ends, then repeat both tests. - Save only the recovered, intended configuration on R1, SW1 and SW2 with
copy running-config startup-config. Do not save the deliberately broken state as the finished lab.
If PC1 cannot reach its own gateway, inspect its address, mask, access port and SW1's router trunk before changing the inter-switch uplink. If PC1 → PC3 works but PC1 → PC2 fails, check R1's connected routes, both host gateways and any host firewall or access-control list (ACL). A missing ping reply alone does not identify the failed device.
Router-on-a-stick saves physical router interfaces, but the data VLANs share the router uplink and forwarding resources. This lab demonstrates the mechanism; it does not measure throughput or prove that the design is suitable for every office.
Explain the results
PC1 reaches PC3 across the two switches while R1 is disconnected. Why can this work?
You remove VLAN 10 only from SW1 Gi1/0/23. Which previously working test is expected to fail first?
Both data subinterfaces on R1 show up/up, but VLAN 20 is missing from SW1's allowed list towards R1. What should you conclude?
Technical references
The switch commands follow Cisco's IOS XE VLAN trunking guide. Router subinterfaces follow its external-router inter-VLAN example. Exact interface names, defaults and output vary by platform. No hardware or simulator execution is claimed.