Router-on-a-stick
One router link, multiple gateways
A Layer 2 switch separates VLANs but does not normally route between them. Router-on-a-stick uses one physical router interface with a separate logical subinterface for each routed VLAN. Each subinterface receives the frames for its assigned tag and has an IP address that can serve as the hosts’ default gateway. Unlike a trunk between switches, this link connects the VLANs to an IP forwarding device.
Build a mental topology
A uses gateway 192.0.2.1 and B uses 198.51.100.1. Both links to hosts are ordinary access ports; only the switch–router link carries tagged data for VLANs 10 and 20. The example uses documentation prefixes, not public endpoints. Assume working interfaces, no overlapping networks, both VLANs allowed, both data VLANs tagged, and a policy permitting the illustrated exchange. Read the diagram as A and B connected to S, with R attached below S.
A 192.0.2.10/24 -- access 10 -- S -- access 20 -- B 198.51.100.20/24 | trunk 10,20 | R .10: 192.0.2.1/24 .20: 198.51.100.1/24Follow the IPv4 packet
A compares B’s IP with its own /24 and chooses its gateway. With an empty ARP cache it resolves the gateway’s MAC inside VLAN 10, not B’s MAC. S adds tag 10 toward R. R selects the directly connected VLAN 20 network, decrements TTL (here by one), updates the IPv4 header checksum, and resolves B’s MAC on VLAN 20 if necessary. R builds a fresh Ethernet frame tagged 20; S removes the tag on the access egress. The IP addresses remain unchanged in this example without NAT. R10 and R20 name the gateway MAC on each VLAN; they need not be numerically distinct.
A -> R (VLAN 10): IP 192.0.2.10 -> 198.51.100.20, TTL 64, MAC A -> R10R -> B (VLAN 20): IP 192.0.2.10 -> 198.51.100.20, TTL 63, MAC R20 -> BRead a configuration excerpt
This static Cisco IOS/IOS XE-style excerpt illustrates subinterface syntax, not a complete or tested configuration. The suffix .10 is a chosen identifier; encapsulation dot1Q 10 binds the tag. A compatible parent interface must be enabled, the switch trunk and native-VLAN handling must agree, and routing must be operational. Interface names and feature support depend on hardware and release. Do not paste this into a real router.
interface GigabitEthernet0/0/0.10 encapsulation dot1Q 10 ip address 192.0.2.1 255.255.255.0interface GigabitEthernet0/0/0.20 encapsulation dot1Q 20 ip address 198.51.100.1 255.255.255.0Trade-offs and practice
The shared link is used once toward R and once back toward S for an inter-VLAN packet. A link failure may remove both gateways; capacity depends on direction, duplex and traffic mix, not a universal halving rule. A same-VLAN exchange can remain switched locally. Reverse the A-to-B example: B resolves 198.51.100.1, R selects VLAN 10 and resolves A. Next compare a multilayer switch.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Router-on-a-stick — knowledge check
Apply the chapter topology and reason from forwarding evidence.
A sends to 198.51.100.20 from VLAN 10. Which IP does A resolve using ARP?
Which setting binds the router subinterface to VLAN 20?
With an initial TTL of 64, what does the example show on VLAN 20?
What is the destination MAC in the outgoing frame from R toward B?
What happens to the source IP without NAT in the example?