Network Bytes · Episode 82 · CCNA 2.1
"Inter-VLAN routing: router on a stick"
Each VLAN is its own network, so traffic between VLANs needs a router. Router on a stick connects one router port to a switch trunk and splits it into subinterfaces, one per VLAN, each tagged with its VLAN and holding the default gateway address for that VLAN.
Why VLANs need a router
A VLAN splits one physical switch into separate networks (see EP30). PCs in VLAN 10 and PCs in VLAN 20 may plug into ports a few centimetres apart, but the switch keeps their traffic apart as if they were on different switches. Each VLAN has its own subnet, for example 192.168.10.0/24 and 192.168.20.0/24.
Moving traffic from one network to another is a router's job. Think of two offices in one building: each has its own staff and its own mail, and anything going from one office to the other passes through the mailroom. The router is that mailroom.
One trunk, many subinterfaces
You could give the router one cable and one port per VLAN, but that runs out of ports quickly. Router on a stick uses just one physical link:
- The switch port facing the router is a trunk (see EP31), so it carries frames for every VLAN, each with an 802.1Q tag that says which VLAN it belongs to.
- On the router, that one physical interface is divided into subinterfaces, such as
G0/0.10andG0/0.20. Each one is a logical interface that handles one VLAN.
The name comes from the picture: the router hangs off the switch on a single "stick" of cable.
Configuring a subinterface
Each subinterface needs two things: the VLAN tag it answers to and an IP address in that VLAN's subnet.
`` interface g0/0.10 encapsulation dot1Q 10 ip address 192.168.10.1 255.255.255.0 ``
encapsulation dot1Q 10 tells the subinterface to handle frames tagged with VLAN 10. The IP address 192.168.10.1 becomes the default gateway that every PC in VLAN 10 uses. The VLAN 20 subinterface gets encapsulation dot1Q 20 and 192.168.20.1. Also bring up the physical interface with no shutdown; the subinterfaces follow its state.
Following one packet
- A PC in VLAN 10 wants to reach a PC in VLAN 20. The destination is in another subnet, so it sends the packet to its default gateway,
192.168.10.1. - The switch sends the frame up the trunk, tagged VLAN 10.
- The router receives it on
G0/0.10, looks up the destination, and finds that192.168.20.0/24is reached throughG0/0.20. - The router sends it back down the same trunk, now tagged VLAN 20, and the switch delivers it to the PC in VLAN 20.
Every inter-VLAN packet crosses the trunk twice, once up and once down. That is fine for a small office, but it makes the trunk a bottleneck in bigger networks.
Try it yourself
In Cisco Packet Tracer (free with a Cisco Networking Academy account), connect a router to a switch and two PCs to the switch. On the switch, put one PC's port in VLAN 10 and the other in VLAN 20, and make the port toward the router a trunk with switchport mode trunk. On the router, run no shutdown on the physical interface and create G0/0.10 and G0/0.20 with the commands above. Give the PCs addresses in their subnets with the matching gateways, then ping from one PC to the other. Bonus: delete one subinterface and watch the ping fail.
Good to know
- Router on a stick (ROAS) uses one physical router interface connected to a switch trunk port, divided into subinterfaces.
- Each subinterface is set with
encapsulation dot1Q <vlan>and an IP address that hosts in that VLAN use as their default gateway. - The physical interface needs
no shutdown; subinterfaces follow its state. - The subinterface number (
.10) matching the VLAN is a convention, not a rule; thedot1Qcommand sets the VLAN. - The native VLAN can instead be handled with
encapsulation dot1Q <vlan> nativeor an IP address on the physical interface; the short skips this. - Because every inter-VLAN packet crosses the same link twice, ROAS suits small networks. Larger ones usually route between VLANs on a Layer 3 switch with SVIs (not covered here).
192.168.10.0/24and192.168.20.0/24are private example subnets (RFC 1918). "Mailroom" is an analogy.
For CCNA learners
CCNA exam topic 2.1 (configure and verify VLANs spanning multiple switches) includes inter-VLAN connectivity. Know how router on a stick works: a trunk to one router interface, a subinterface per VLAN with encapsulation dot1Q <vlan> and the VLAN's gateway IP, and why each packet crosses the trunk twice.
Answer to the comment question
4 subinterfaces. Router on a stick needs one subinterface per VLAN, so four VLANs need four subinterfaces (for example G0/0.10, G0/0.20, G0/0.30 and G0/0.40), each with its own encapsulation dot1Q tag and gateway address. They all share the same single trunk link.
Test your knowledge
Quick quiz: "Inter-VLAN routing: router on a stick"
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- Cisco Press, "CCNA 200-301 Official Cert Guide excerpt: IP Routing in the LAN": router on a stick uses one router interface on a switch trunk with subinterfaces configured with
encapsulation dot1q <vlan>before the IP address - Networkacademy.io, "Router on a stick": each subinterface IP is the default gateway for hosts in that VLAN; the switch port toward the router is a trunk
- Cisco, "CCNA 200-301 v1.1 exam topics": 2.1 configure and verify VLANs spanning multiple switches, including inter-VLAN connectivity
- IETF, "RFC 1918, Address Allocation for Private Internets": 192.168.10.0/24 and 192.168.20.0/24 are private example subnets
Video transcript
Two VLANs share one switch, but they can't talk. How do you connect them?
Each VLAN is its own network, so traffic between them needs a router. Think of two offices sending mail through one mailroom.
Connect the switch to the router with one trunk link. On the router, split that one port into subinterfaces, one per VLAN. That's router on a stick.
Each subinterface gets a VLAN tag and an IP address, which becomes the default gateway for its VLAN.
A PC in VLAN ten sends a packet up the trunk. The router routes it and sends it back down, tagged VLAN twenty.
Four VLANs need to talk through router on a stick. How many subinterfaces does the router need? Comment your answer below!
That's your byte.
More from Network Bytes
- EP80"Floating static routes"
- EP81"TFTP and FTP: backing up configs"
- EP83"DHCP relay: ip helper-address"
- EP84"Dynamic ARP Inspection"