Hands-On Lab: Configuring Inter-VLAN Routing (Router on a Stick)

This hands-on lab configures inter-VLAN routing using a single router interface divided into subinterfaces, connecting to a switch trunk to route traffic between two VLANs through one physical link.

Router on a StickSubinterface Configuration802.1Q Encapsulation

~3 min read · Updated Sep 22, 2026

Lab Objective

Configure a router with two subinterfaces on a single physical interface, connect it to a switch trunk carrying two VLANs, and verify hosts in each VLAN can reach each other through the router.

Lab Purpose

Before a Layer 3 switch with SVIs is available or justified, router-on-a-stick remains a common, simple way to enable inter-VLAN routing using a single router interface and a trunk link, especially in smaller networks or lab environments.

Lab Topology

R1 ---- Gi0/0 (trunk) ---- Switch1

Switch1:
  Gi1/0/1 ---- PC-A (VLAN 10): 192.168.10.10/24
  Gi1/0/2 ---- PC-B (VLAN 20): 192.168.20.10/24
  Gi1/0/24 ---- trunk to R1

R1 subinterfaces:
  Gi0/0.10: 192.168.10.1/24 (VLAN 10)
  Gi0/0.20: 192.168.20.1/24 (VLAN 20)

Task 1: Configure the Switch Trunk and VLANs

Create VLANs 10 and 20 on Switch1, assign Gi1/0/1 to VLAN 10 and Gi1/0/2 to VLAN 20, and configure Gi1/0/24 as a trunk allowing both VLANs.

Task 2: Configure the Router's Physical Interface

Bring up Gi0/0 on R1 without assigning it an IP address directly.

Task 3: Configure the Subinterfaces

Create subinterfaces Gi0/0.10 and Gi0/0.20 with appropriate 802.1Q encapsulation and IP addresses.

Task 4: Configure PC Default Gateways

Set PC-A's default gateway to R1's Gi0/0.10 address, and PC-B's to Gi0/0.20's address.

Task 5: Verify Inter-VLAN Connectivity

Confirm PC-A can ping PC-B across the two VLANs.

Solution and Verification

Switch1(config)# vlan 10
Switch1(config-vlan)# exit
Switch1(config)# vlan 20
Switch1(config-vlan)# exit

Switch1(config)# interface gigabitethernet1/0/1
Switch1(config-if)# switchport mode access
Switch1(config-if)# switchport access vlan 10
Switch1(config-if)# exit

Switch1(config)# interface gigabitethernet1/0/2
Switch1(config-if)# switchport mode access
Switch1(config-if)# switchport access vlan 20
Switch1(config-if)# exit

Switch1(config)# interface gigabitethernet1/0/24
Switch1(config-if)# switchport mode trunk

R1(config)# interface gigabitethernet0/0
R1(config-if)# no shutdown
R1(config-if)# exit

R1(config)# interface gigabitethernet0/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 gigabitethernet0/0.20
R1(config-subif)# encapsulation dot1Q 20
R1(config-subif)# ip address 192.168.20.1 255.255.255.0

PC-A: default gateway 192.168.10.1
PC-B: default gateway 192.168.20.1

PC-A> ping 192.168.20.10

Reply from 192.168.20.10: bytes=32 time=2ms

R1# show ip route

C    192.168.10.0/24 is directly connected, GigabitEthernet0/0.10
C    192.168.20.0/24 is directly connected, GigabitEthernet0/0.20

Key Takeaway

Each subinterface's encapsulation dot1Q command must exactly match the VLAN number carried on the corresponding trunk tag — forgetting this command, or specifying the wrong VLAN number, is the most common cause of a router-on-a-stick configuration that appears correct but fails to route traffic for that specific VLAN.

Written & researched by Dr. Shahin Siami

Related Articles

Hands-On Lab: Configuring IPv6 Static Routes

This hands-on lab configures static routes for IPv6 destinations between two routers, mirroring the IPv4 static routing syntax covered earlier in this series while highlighting the IPv6-specific command keyword and address format.

Continue

Hands-On Lab: Configuring Default Static Routes

This hands-on lab configures a default static route on an edge router to reach the internet through an ISP connection, demonstrating how a single route can represent every otherwise-unknown destination rather than requiring individual routes for each one.

Continue

Hands-On Lab: Configuring and Naming Static Routes

This hands-on lab configures static routes with descriptive names attached using the name keyword, improving documentation and making the routing table significantly easier to interpret for anyone reviewing the configuration later.

Continue

Hands-On Lab: Configuring Static Routing via IP Addresses

This hands-on lab configures static routes using a next-hop IP address rather than an outgoing interface, the generally preferred syntax, and compares the resulting routing table entry against the interface-based approach from the previous lab.

Continue

Hands-On Lab: Configuring Static Routing via Interfaces

This hands-on lab configures static routes using an outgoing interface rather than a next-hop IP address, demonstrating this approach's suitability for point-to-point links and its important limitation on multi-access networks.

Continue

Hands-On Lab: Installing a Wireless LAN Controller

This hands-on lab performs the initial setup of a Wireless LAN Controller, joins a lightweight access point to it, and creates a centrally managed WLAN, demonstrating the controller-based architecture that scales far beyond standalone access points.

Continue