Inter-VLAN Routing with Router-on-a-Stick

15 minsSimneta AcademyOct 17, 2026

Learn how to route traffic between isolated VLANs using a single physical cable. Configure 802.1Q trunking on a Layer 2 switch and create virtual sub-interfaces on a Cisco router to enable smooth Inter-VLAN routing.

In enterprise network design, separating departments like Sales (VLAN 10) and Engineering (VLAN 20) on a Layer 2 switch is a fundamental security best practice. It confines noisy broadcast frames to their own segment and stops curious employees from browsing confidential servers. However, departments cannot operate in total isolation forever—engineers occasionally need to transfer project deliverables or submit expense reports to the Sales accounting software.

Because switches operate strictly at Layer 2, they cannot inspect IP headers or move packets across VLAN boundaries on their own. Running individual physical cables from the router to each separate VLAN port works in small prototypes, but it rapidly exhausts valuable router interfaces and clutters server racks with expensive copper runs.

The industry standard design is Router-on-a-Stick (ROAS). By connecting a single gigabit Ethernet cable between the switch and router and carving that single physical connection into multiple virtual sub-interfaces using 802.1Q encapsulation, you achieve secure Layer 3 routing between all internal departments.

Implementing router-on-a-stick requires establishing an 802.1Q trunk between switch and router, dividing the physical interface into dedicated logical sub-interfaces, and routing packets between subnets across the same physical link.

Network Architecture Plan

SegmentInterfaceSubnet / AddressFunctional Role
Core Router PhysicalGigabitEthernet0/0/0Unnumbered LinkPhysical carrier link connecting switch trunk
Sales Sub-interfaceGigabitEthernet0/0/0.10192.168.10.1/24Default Gateway for Sales Department (VLAN 10)
Engineering Sub-interfaceGigabitEthernet0/0/0.20192.168.20.1/24Default Gateway for Engineering Department (VLAN 20)
Switch Uplink TrunkFastEthernet0/24802.1Q TrunkCarries tagged frames from all local VLANs to router
Sales WorkstationFastEthernet0192.168.10.10/24Sales endpoint (Default Gateway: 192.168.10.1)
Engineer WorkstationFastEthernet0192.168.20.10/24Engineering endpoint (Default Gateway: 192.168.20.1)
1

Isolating Switch Broadcast Domains

Before establishing inter-VLAN routing, configure the access ports on your Layer 2 switch. Create VLAN 10 for Sales and VLAN 20 for Engineering.

Assign switch port FastEthernet0/1 to VLAN 10 and port FastEthernet0/2 to VLAN 20. When an access port receives an untagged frame from a workstation, the switch inserts an internal VLAN tag and keeps that frame strictly inside that broadcast domain.

If you attempt to ping the Engineer Workstation (192.168.20.10) from the Sales Workstation (192.168.10.10) right now, the ping fails immediately. The switch refuses to forward frames across VLAN boundaries because it lacks a Layer 3 routing engine.

To allow communication, frames must exit the switch, travel to an upstream router to cross the subnet boundary, and return back down to the destination VLAN.

Configuring Switch Access Ports and VLANs
Switch# configure terminal
# Step 1: Create departmental VLANs
Switch(config)# vlan 10
Switch(config-vlan)# name Sales
Switch(config-vlan)# exit
Switch(config)# vlan 20
Switch(config-vlan)# name Engineering
Switch(config-vlan)# exit

# Step 2: Assign access ports
Switch(config)# interface FastEthernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 10
Switch(config-if)# exit

Switch(config)# interface FastEthernet0/2
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 20
Switch(config-if)# exit

Understanding Broadcast Domain Isolation:

vlan 10 / vlan 20: Creates distinct Layer 2 broadcast domains inside the switch CAM memory.
switchport access vlan X: Strips all 802.1Q tags when delivering frames to client workstations, ensuring standard end-user PCs receive untagged Ethernet frames.
Broadcast Containment: When Sales PC sends an ARP request for an unknown IP, the switch floods the broadcast only out of ports in VLAN 10. Engineering PC on VLAN 20 never sees the broadcast, saving network card processing cycles.
Field Architecture Insight

Access Port Security: Always configure switchport mode access explicitly on end-user ports. Leaving ports in default dynamic mode allows attackers to negotiate trunks and hop into unauthorized VLANs.

2

Building the 802.1Q Trunk

To carry traffic from multiple VLANs over a single cable up to the router, configure the switch uplink port FastEthernet0/24 as an 802.1Q trunk link.

When a frame departs an access port and enters a trunk link, the switch inserts a 4-byte 802.1Q header into the Ethernet frame. This header contains a 12-bit VLAN Identifier (VLAN ID) that tells the receiving router exactly which subnet the packet originated from.

Connect port FastEthernet0/24 on the switch to port GigabitEthernet0/0/0 on the Cisco router using a standard Cat6 copper cable.

On the switch interface CLI, execute switchport mode trunk and enable the link with no shutdown.

Switch Trunk Uplink Configuration CLI
Switch# configure terminal
Switch(config)# interface FastEthernet0/24
Switch(config-if)# description Uplink-to-Router-ROAS
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk allowed vlan 10,20
Switch(config-if)# no shutdown
Switch(config-if)# exit

Inside the 4-Byte 802.1Q Tag:

TPID (0x8100): Tag Protocol Identifier confirming this is an IEEE 802.1Q tagged frame.
Priority (PCP): 3 bits used for Class of Service (CoS) quality of service prioritization.
VLAN ID (VID): 12 bits identifying the specific VLAN number (values 1 through 4094).
switchport trunk allowed vlan 10,20: Restricts trunk traffic to only our active departments, preventing unnecessary broadcast leakage from other internal networks.
Field Architecture Insight

Real-world field story: A junior engineer configured IP addresses on sub-interfaces but forgot the encapsulation dot1Q command. The router received tagged frames from the switch trunk, had no idea which sub-interface owned them, and silently discarded every single inter-department packet.

3

Configuring Router Dot1Q Subinterfaces

On the Cisco router, the physical interface GigabitEthernet0/0/0 does not receive an IP address. Instead, you enable the physical carrier port using no shutdown, and then create logical sub-interfaces by appending a dot and a number, such as interface GigabitEthernet0/0/0.10.

Each sub-interface requires a strict sequence of configuration commands:

1interface GigabitEthernet0/0/0.10: The number .10 is arbitrary, but engineering best practice dictates matching the VLAN ID for clarity.
2encapsulation dot1Q 10: This is mandatory before assigning an IP. It binds the virtual sub-interface to 802.1Q tag 10. If you try to type ip address first, Cisco IOS will reject the command with an error.
3ip address 192.168.10.1 255.255.255.0: This assigns the default gateway IP address for all workstations in VLAN 10.

Repeat the exact same sequence for sub-interface .20 with encapsulation dot1Q 20 and IP 192.168.20.1/24.

Creating Logical Sub-Interfaces on Cisco Router
Router# configure terminal
# Step 1: Bring up the physical carrier port (no IP assigned)
Router(config)# interface GigabitEthernet0/0/0
Router(config-if)# no shutdown
Router(config-if)# exit

# Step 2: Sub-interface for VLAN 10 (Sales Gateway)
Router(config)# interface GigabitEthernet0/0/0.10
Router(config-subif)# encapsulation dot1Q 10
Router(config-subif)# ip address 192.168.10.1 255.255.255.0
Router(config-subif)# exit

# Step 3: Sub-interface for VLAN 20 (Engineering Gateway)
Router(config)# interface GigabitEthernet0/0/0.20
Router(config-subif)# encapsulation dot1Q 20
Router(config-subif)# ip address 192.168.20.1 255.255.255.0
Router(config-subif)# exit

Understanding Sub-Interface Binding Mechanics:

The Parent Interface Rule: The physical interface (Gi0/0/0) must be powered on with no shutdown. If the parent port is administratively down, all sub-interfaces collapse automatically regardless of their individual states.
The Encapsulation Prerequisite: Cisco IOS enforces strict syntax ordering: you must define encapsulation dot1Q <vlan> before the system permits an ip address command on a sub-interface.
Gateway IP Placement: Each sub-interface acts as the default gateway router interface for that respective VLAN subnet. Workstations in Sales point their default gateway to 192.168.10.1, while Engineering points to 192.168.20.1.
Field Architecture Insight

Sub-Interface Numbering Tip: Although Cisco IOS allows naming subinterfaces arbitrarily (e.g. Gi0/0/0.999 for VLAN 10), always match the subinterface number to the VLAN ID (Gi0/0/0.10 for VLAN 10) to prevent operational confusion.

4

Verifying Connected Routing Tables

Open the CLI console on the Cisco router and run show ip route connected to examine the sub-interface bindings in the routing table:

Observe how the router operating system registers each departmental subnet as directly attached to its corresponding logical sub-interface.

Terminal Session Output
Console Verification
Router# show ip route connected
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
C 192.168.10.0/24 is directly connected, GigabitEthernet0/0/0.10
L 192.168.10.1/32 is directly connected, GigabitEthernet0/0/0.10
C 192.168.20.0/24 is directly connected, GigabitEthernet0/0/0.20
L 192.168.20.1/32 is directly connected, GigabitEthernet0/0/0.20

Routing Table Output Breakdown:

C - Connected Subnets: The letter C confirms directly connected networks. Subnet 192.168.10.0/24 maps to Gi0/0/0.10, and 192.168.20.0/24 maps to Gi0/0/0.20.
L - Local Host Routes: The letter L shows local /32 host routes representing the router own gateway IP addresses on each sub-interface.
Direct Inter-VLAN Routing: Because both subnets are directly connected in the exact same routing table, the router routes packets between VLAN 10 and VLAN 20 automatically without needing static routes or dynamic routing protocols.
Field Architecture Insight

Interface Status Prerequisite: If show ip route does not list your subinterfaces, check show ip interface brief. Subinterfaces remain down until the parent physical interface achieves an up/up operational state.

5

Tracing Inter-VLAN Packet Traversal

Open the CLI terminal on the Sales Workstation (192.168.10.10) and send an ICMP ping to the Engineer Workstation at 192.168.20.10 to test inter-VLAN routing:

Watch the packet travel up the trunk cable to the router and return down the same physical cable into the destination VLAN.

Terminal Session Output
Console Verification
PC-Sales:~$ ping 192.168.20.10
PING 192.168.20.10 (192.168.20.10) 56(84) bytes of data.
64 bytes from 192.168.20.10: icmp_seq=1 ttl=63 time=0.84 ms
64 bytes from 192.168.20.10: icmp_seq=2 ttl=63 time=0.59 ms
--- 192.168.20.10 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max = 0.590/0.715/0.840 ms

Tracing the Complete Inter-VLAN Packet Journey:

1Local Subnet Comparison: Sales PC checks its subnet mask. Seeing that 192.168.20.10 is outside its local /24 subnet, it forwards the packet to default gateway 192.168.10.1.
2Switch Tagging: The frame enters switch port Fa0/1 (VLAN 10). The switch forwards it out trunk port Fa0/24, inserting an 802.1Q header with VLAN ID: 10.
3Router Ingress & Lookup: The router receives the tagged frame on Gi0/0/0. It reads VLAN tag 10 and directs the frame to sub-interface Gi0/0/0.10. The router strips the 802.1Q header, decrements the TTL from 64 to 63, and inspects its routing table for 192.168.20.10.
4Router Egress & Retagging: The routing table points to Gi0/0/0.20. The router encapsulates the packet with a new 802.1Q header containing VLAN ID: 20 and transmits it back down the exact same cable.
5Destination Delivery: The switch receives the frame on Fa0/24, inspects VLAN tag 20, strips the tag, and delivers the untagged frame out access port Fa0/2 to the Engineer Workstation.

The 0% packet loss and steady 0.7ms latency prove that inter-VLAN routing is fully operational.

Field Architecture Insight

Bandwidth Consideration: In high-traffic corporate data centers, sending traffic up and down a single cable (the stick) can create bottlenecks. Modern enterprise networks migrate high-volume Inter-VLAN routing to Layer 3 Multilayer Switches using Switched Virtual Interfaces (SVIs).

Key Takeaways: Router-on-a-Stick enables inter-VLAN routing over a single physical cable using 802.1Q trunking and virtual router sub-interfaces. Each sub-interface serves as the default gateway for its respective departmental broadcast domain.
#router-on-a-stick #inter-vlan #sub-interfaces #802.1q #cisco-ios #vlan-routing #gateway

Discussion & Community Notes

Ask questions, share configuration tips, or discuss this laboratory topology.

0 Comments
Posting as Guest • 1-level replies supported
Loading discussion thread...