Configure Router-on-a-Stick Inter-VLAN Routing
Learn how to configure 802.1Q router-on-a-stick inter-VLAN routing across dual-switch trunks, subinterfaces, and separated host VLAN networks.
In a two-building campus network, network engineers separate departments into Virtual LANs to block noisy broadcasts. Faculty laptops sit securely in VLAN 10, while students connect to VLAN 20.
Security is tight, but a new problem quickly emerges. Teachers cannot share lesson plans with students, and students cannot reach the department printer.
By default, devices in different VLANs cannot talk to each other without a Layer 3 routing engine. In this hands-on lab, we configure Router-on-a-Stick (ROAS) using 802.1Q subinterfaces on a single Cisco router link to bridge our separated campus networks.
The Real-World Dilemma: Legacy Routing vs Single Stick
In the early days of networking, connecting two VLANs required two separate physical router ports. A network engineer ran one cable from the switch for VLAN 10 and another cable for VLAN 20.
This legacy approach breaks down quickly in modern networks. An enterprise campus might have 15 or 30 VLANs. Buying a router with 30 physical Ethernet interfaces wastes budget and consumes rack space.
Router-on-a-Stick solves this problem elegantly. We connect just one physical cable between the core switch and router, then split that single link into virtual subinterfaces.
How 802.1Q Frame Tagging Works on Trunk Links
Standard access ports carry normal, untagged Ethernet frames. A laptop never knows which VLAN it belongs to.
When a frame leaves a switch over a trunk link, the switch inserts a 4-byte IEEE 802.1Q header directly behind the source MAC address. This tag carries a 12-bit VLAN identifier so the receiving switch or router knows exactly where the frame belongs.
Figure 1. The 802.1Q Frame Tagging Lifecycle Across Trunk Ports
Figure 1 shows the journey across the trunk. When the frame reaches the Cisco router, the router inspects the VLAN tag and routes the payload to the matching subinterface.
One special network, the Native VLAN (VLAN 99), carries untagged management frames across the trunk. If the native VLAN does not match on both switches, Cisco Discovery Protocol (CDP) will trigger continuous console mismatch alarms.
Comparing Traffic Paths: Intra-VLAN vs Inter-VLAN
Not every packet needs to travel up to the router. Understanding the difference between local switched traffic and routed traffic is vital for network performance.
Figure 2. Switched Layer 2 Intra-VLAN Path vs Routed Layer 3 Bounce
Notice the two distinct paths shown in Figure 2:
- Intra-VLAN Path (Green): When PC1 in Faculty VLAN 10 pings PC3 in Building B (also in VLAN 10), switch S1 tags the frame and sends it over the inter-switch trunk directly to S2. The frame stays in Layer 2, and router R1 never sees it.
- Inter-VLAN Path (Orange): When PC1 in VLAN 10 pings PC2 in VLAN 20, PC1 knows the destination IP is on another subnet. It forwards the frame to its default gateway (
192.168.10.1) on router R1. The router accepts the frame, strips the VLAN 10 tag, routes the packet to subinterface .20, attaches a VLAN 20 tag, and sends it back down the trunk to S1.
The Golden Rules of Cisco Subinterface Configuration
Before configuring a router-on-a-stick setup, remember three essential rules that prevent common setup errors:
- Enable the Parent Interface First: The physical interface (
GigabitEthernet0/0/1) does not get an IP address, but you must runno shutdownon it. If the parent port stays down, all subinterfaces stay down. - Encapsulation Before IP: You must type
encapsulation dot1Q <vlan-id>before setting the IP address. If you try to enter an IP address first, Cisco IOS rejects the command with an error. - Match the Native VLAN: For the native management VLAN, add the
nativekeyword so the router knows untagged trunk frames belong to VLAN 99.
Figure 3. Virtual Subinterface Architecture on Cisco Router Port
Campus Addressing and Interface Plan
Here is the complete network mapping for the two campus switches, router subinterfaces, and host PCs:
| Device | Interface | IP Address | VLAN ID & Purpose |
|---|---|---|---|
| R1 | Gi0/0/1.10 | 192.168.10.1/24 | VLAN 10 Gateway (Faculty) |
| R1 | Gi0/0/1.20 | 192.168.20.1/24 | VLAN 20 Gateway (Student) |
| R1 | Gi0/0/1.99 | Unnumbered | VLAN 99 Native Management |
| S1 | VLAN 99 | 192.168.99.11/24 | Switch S1 Management SVI |
| S2 | VLAN 99 | 192.168.99.12/24 | Switch S2 Management SVI |
| PC1 / PC3 | FastEthernet0 | .10.10 / .10.20 | VLAN 10 Faculty Workstations |
| PC2 / PC4 | FastEthernet0 | .20.10 / .20.20 | VLAN 20 Student Workstations |
Step-by-Step Configuration Guide
Follow these sequential steps on switches S1, S2, and router R1:
Create VLANs and Access Ports on S1 and S2
Define VLAN 10 (Faculty), VLAN 20 (Student), and VLAN 99 (Management). Assign access ports Fa0/11 to VLAN 10 and Fa0/18 to VLAN 20.
S1(config)# vlan 10
S1(config-vlan)# name Faculty
S1(config-vlan)# vlan 20
S1(config-vlan)# name Student
S1(config-vlan)# vlan 99
S1(config-vlan)# name Management_Native
S1(config-vlan)# exit
S1(config)# interface FastEthernet0/11
S1(config-if)# switchport mode access
S1(config-if)# switchport access vlan 10
S1(config)# interface FastEthernet0/18
S1(config-if)# switchport mode access
S1(config-if)# switchport access vlan 20
Configure 802.1Q Trunks on Switches
Configure Fa0/1 as an 802.1Q trunk between S1 and S2, and Fa0/5 as the uplink trunk to router R1 with native VLAN 99.
S1(config)# interface FastEthernet0/1
S1(config-if)# switchport mode trunk
S1(config-if)# switchport trunk native vlan 99
S1(config)# interface FastEthernet0/5
S1(config-if)# switchport mode trunk
S1(config-if)# switchport trunk native vlan 99
Configure Logical Subinterfaces on Router R1
Bring up parent port Gi0/0/1, then configure virtual subinterfaces with dot1Q encapsulation and gateway IP addresses.
R1(config)# interface GigabitEthernet0/0/1
R1(config-if)# no shutdown
R1(config-if)# exit
R1(config)# interface GigabitEthernet0/0/1.10
R1(config-subif)# encapsulation dot1Q 10
R1(config-subif)# ip address 192.168.10.1 255.255.255.0
R1(config)# interface GigabitEthernet0/0/1.20
R1(config-subif)# encapsulation dot1Q 20
R1(config-subif)# ip address 192.168.20.1 255.255.255.0
R1(config)# interface GigabitEthernet0/0/1.99
R1(config-subif)# encapsulation dot1Q 99 native
Verification and Routing Table Inspection
To confirm that router R1 is ready to route traffic between VLANs, check its routing table using show ip route:
Figure 4. Router Routing Table Subinterface Resolution and ARP Timing
R1# show ip route connected
C 192.168.10.0/24 is directly connected, GigabitEthernet0/0/1.10
C 192.168.20.0/24 is directly connected, GigabitEthernet0/0/1.20
Both subnets appear as directly connected networks pointing to their respective subinterfaces.
Now test connectivity from PC1. First, ping PC3 (192.168.10.20). The ping succeeds with 100% response rate over the Layer 2 switch trunk. Next, ping PC2 (192.168.20.10). The first ICMP packet may drop while R1 performs ARP resolution, after which all subsequent packets flow smoothly across the router-on-a-stick uplink.
Discussion & Community Notes
Ask questions, share configuration solutions, or discuss this practice lab.
