Inter-VLAN routing
Three ways to route between VLANs: a separate router interface per VLAN (legacy), a single router-on-a-stick using subinterfaces, and an L3 switch with SVIs (Switched Virtual Interfaces). This chapter walks through the two modern patterns end to end.
What you'll learn
- Configure router-on-a-stick with subinterfaces and 802.1Q encapsulation.
- Configure SVIs on an L3 switch and enable ip routing.
- Choose between router-on-a-stick and L3 switch for a given scale.
Router-on-a-stick — one trunk, many VLANs
Connect a single router interface to a switch trunk port. Create one subinterface on the router per VLAN, each with its own IP and 'encapsulation dot1Q <vlan>' command. Each PC's default gateway is the router subinterface IP for its VLAN.
The physical port carries no address of its own; it only has to be up (no shutdown). The encapsulation goes on each subinterface, never on the physical port, which every VLAN shares. A subinterface number such as .10 is only a label: the VLAN it serves is set by encapsulation dot1Q, and matching the two numbers is a convention that keeps the configuration readable.
R1(config)# interface Gi0/0
R1(config-if)# no shutdown
R1(config)# interface Gi0/0.10
R1(config-subif)# encapsulation dot1Q 10
R1(config-subif)# ip address 10.0.10.1 255.255.255.0
R1(config)# interface Gi0/0.20
R1(config-subif)# encapsulation dot1Q 20
R1(config-subif)# ip address 10.0.20.1 255.255.255.0SVIs on an L3 switch — line-rate routing
An SVI (interface VlanX) is a virtual L3 interface inside a switch that represents the entire VLAN as a single routable interface. With ip routing enabled the switch forwards inter-VLAN traffic in hardware — far faster than a single router-on-a-stick link.
Switch(config)# ip routing
Switch(config)# interface Vlan10
Switch(config-if)# ip address 10.0.10.1 255.255.255.0
Switch(config-if)# no shutdown
Switch(config)# interface Vlan20
Switch(config-if)# ip address 10.0.20.1 255.255.255.0
Switch(config-if)# no shutdown9 more sections in this chapter, plus a 4-question quiz and a hands-on lab.
Modules 2–8 are part of the Course & Lab Pass and All-Access Max — start with a free account
You can see the title, summary, learning objectives and the opening sections. The rest of this chapter, like all of modules 2–8, comes with the Course & Lab Pass and All-Access Max. A free account opens Module 1: How Networks Work end-to-end and saves your labs — start there, no card required.
- Read every chapter in Module 1 — How Networks Work
- Save labs of up to 5 devices
- Save up to 3 topologies
- See the full course syllabus + chapter titles
Free account · no card required · compare plans any time
Build it step by step
- Router on a stickSplit one switch into two VLANs and route between them over a single router port. · 8 steps · ~18 min · 4 devices
- Route between VLANs on the switchGive one switch an SVI in each VLAN, find out why the VLANs still can't talk, then turn on ip routing — inter-VLAN routing with no router at all. · 6 steps · ~15 min · 3 devices
- Campus capstonePut it all together: two wiring closets, two VLANs, DHCP for the desks, and one public address for the whole site. · 9 steps · ~35 min · 8 devices
- Branch office capstoneStaff and guests on one switch: guests lease an address the moment they plug in, reach the internet, and never see a staff file. · 10 steps · ~40 min · 7 devices