Inter-VLAN Routing
VLANs separate traffic; sooner or later the separated parts must talk. Moving frames between VLANs is a Layer 3 job, and there are exactly two classic ways to do it: a physical router with subinterfaces on one trunk (“router-on-a-stick”) or a multilayer switch routing with SVIs. Both use the same idea — a default gateway in every VLAN — and this lesson makes the two approaches interchangeable in your head.
- Explain why inter-VLAN traffic must be routed at Layer 3.
- Configure router-on-a-stick: subinterfaces with encapsulation dot1q.
- Understand the native VLAN subinterface (encapsulation dot1q
native). - Configure SVIs on a multilayer switch and enable routing with ip routing.
- Compare router-on-a-stick, SVIs, and the Layer 3 switch approach in a table.
- Verify inter-VLAN routing with ping and show ip route.
Why VLANs need a router
Two hosts in different VLANs do not share a broadcast domain and cannot exchange frames directly. Their frames are intended for a Layer 3 destination: the default gateway of each VLAN. The router or multilayer switch receives the frame, strips the Layer 2 header, checks the destination IP, looks up a route, and re-encapsulates the packet into a frame for the destination VLAN. That hop — de-frame, route, re-frame — is called inter-VLAN routing.
The design consequence from Lesson 12 now pays off: every VLAN must have a default gateway that exists in that VLAN. If your gateway address is in VLAN 1 but your PC is in VLAN 10, the PC can reach local neighbours and nothing else. Inter-VLAN routing is fundamentally a gateway-address design exercise.
Router-on-a-stick
The cheapest way to route between VLANs uses one router, one physical interface, and one trunk. The router’s interface is split into subinterfaces — logical divisions of a physical port — and each subinterface owns one VLAN as its default gateway.
R1(config)# interface gigabitethernet 0/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 gigabitethernet 0/0.20 R1(config-subif)# encapsulation dot1q 20 R1(config-subif)# ip address 192.168.20.1 255.255.255.0 R1(config-subif)# end
R1 now answers as 192.168.10.1 for VLAN 10 and 192.168.20.1 for VLAN 20 on the same physical cable.
The switch side needs the matching half: the port facing the router must be a trunk carrying VLANs 10
and 20. Hosts in VLAN 10 set their gateway to 192.168.10.1; hosts in VLAN 20 use 192.168.20.1. Frames
from each VLAN arrive tagged on the trunk, and the router’s subinterface accepts only frames
whose tag matches its own encapsulation dot1q number.
Subinterfaces and encapsulation dot1q
The two commands that do the work are the subinterface number (arbitrary, but by convention the VLAN number) and encapsulation dot1q <vlan>. The latter is the whole trick: it tells the router, “on this logical interface, accept and emit frames tagged with VLAN x.” Note the absence of no shutdown — you cannot shut down a subinterface that has never been the point of argument, but you can shut down the parent physical interface, which kills all subinterfaces. Also observe that the physical interface itself carries no IP address in this design; addressing lives on the subinterfaces.
A common mistake is forgetting that the switch trunk must actually permit those VLANs. If the trunk allows only VLAN 10, the router never sees a VLAN 20 frame and its Gi0/0.20 gateway points into nothing. Verify the trunk’s allowed list (Lesson 14) before blaming the router.
encapsulation dot1q 10 is often given as the answer to “which command binds a
subinterface to VLAN 10?” Remember it exactly — it is encapsulation dot1q,
not simply vlan.
The native subinterface
If the trunk has a non-default native VLAN, one subinterface must claim it, and it must use the native keyword so the router knows those frames arrive untagged:
R1(config)# interface gigabitethernet 0/0.99 R1(config-subif)# encapsulation dot1q 99 native R1(config-subif)# ip address 192.168.99.1 255.255.255.0
Without the native keyword, the router expects native-VLAN frames to be tagged, sees
untagged traffic, and drops it. Conversely, if a subinterface is marked native but the trunk’s
native VLAN is different, everything mismatches. The rule: native on the switch, native on the
router, and they must agree.
SVIs on a multilayer switch
A switch that can route (a multilayer switch, or Layer 3 switch) needs no physical router. You create a virtual Layer 3 interface per VLAN — a Switch Virtual Interface (SVI) — give it the gateway address, and turn on IP routing:
S1(config)# ip routing ! enable Layer 3 forwarding on the switch S1(config)# interface vlan 10 S1(config-if)# ip address 192.168.10.1 255.255.255.0 S1(config-if)# no shutdown S1(config-if)# exit S1(config)# interface vlan 20 S1(config-if)# ip address 192.168.20.1 255.255.255.0 S1(config-if)# no shutdown S1(config-if)# end
The first command, ip routing, is the boundary between a Layer 2 switch and a Layer 3
switch: without it, the SVIs exist as management interfaces but never forward packets between VLANs.
With it, the switch routes internally at wire speed. Hosts still point their default gateways at the
SVI addresses (192.168.10.1 and 192.168.20.1), exactly as they would with the router.
ip address). The SVI is also how you SSH, Telnet,
or ping the switch itself — access ports do not carry IP addresses.
Layer 3 switching
The multilayer switch routes with SVIs and hardware tables rather than subinterfaces on a shared trunk. Traffic between VLAN 10 and VLAN 20 on the same switch never leaves the chassis, which removes the bottleneck of a single router cable. This is why campus designs use Layer 3 switches in the core and reserve routers for the WAN edge. The IP gateway design is identical to router-on-a-stick; only the plumbing differs.
Comparison table
| Characteristic | Router-on-a-stick | SVI (multilayer switch) |
|---|---|---|
| Device | External router | Layer 3 switch |
| Interface per VLAN | Subinterface (Gi0/0.10) | SVI (interface vlan 10) |
| Key commands | encapsulation dot1q 10, ip address | ip routing, interface vlan 10, ip address |
| Hardware | One physical trunk shared by all VLANs | Traffic routed inside the switch fabric |
| Performance | Limited by the single trunk and router CPU | Near wire-speed, scales with the switch fabric |
| Typical use | Small sites, labs, few VLANs | Campus cores, many VLANs |
Verification and traps
After configuring either method, the verification sequence is short and satisfying:
S1# show ip route ! connected routes for each SVI appear S1# ping 192.168.20.10 ! reach the far-VLAN host through the SVI
Three traps to rule out when inter-VLAN ping fails:
- Host gateway wrong. The PC’s default gateway is not the gateway of its own VLAN. A PC in VLAN 10 must use the VLAN 10 gateway address, never the VLAN 20 one.
ip routingnot enabled. On a Layer 3 switch the SVIs are up but the switch will not forward between them.show ip routereveals the problem: only directly connected and static routes exist, but no forwarding.- Trunk/native mismatch. On router-on-a-stick, the switch trunk does not carry the VLAN, or the native keyword is missing. The router receives nothing and the subinterface is effectively absent.
ip routing — that
command is only meaningful on a Layer 3 switch. Routers route by default.
ip routing on a switch flips the behaviour of its SVIs from management-only to actual
packet forwarding between VLANs.
The vocabulary you need
Every term below appears in the lesson text above. Select one to read its definition, then use the quiz at the end to check what stuck.
Review
Check what you have learned with these review questions.
Sources & references
- Cisco. CCNA (200-301) Exam Topics. cisco.com.
- IETF. Request for Comments (RFCs). rfc-editor.org.
- IANA. Internet Assigned Numbers Authority registries. iana.org.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.