By the end of this lesson you can
- Compare legacy, router on a stick and Layer 3 switch inter-VLAN routing
- Configure 802.1Q subinterfaces including the native VLAN
- Configure SVIs, ip routing and a routed port on a Layer 3 switch
- Configure HSRP version 2 with priority and preempt, and explain the hijack risk
Three ways to route between VLANs
VLANs separate hosts at Layer 2. To let VLAN 10 reach VLAN 20 at all, something must route between their subnets, and every PC needs that device as its default gateway.
| Method | How | Good for | Watch out |
|---|---|---|---|
| Legacy | One router interface per VLAN | Teaching only | Burns router ports and switch ports. |
| Router on a stick | One trunk to a router, one subinterface per VLAN | Small sites, labs | All inter-VLAN traffic shares one physical link. |
| Layer 3 switch | ip routing plus an SVI per VLAN | Most campus networks | Routing happens in switch hardware at full speed; filter it with ACLs. |
Router on a stick
R1(config)#interface GigabitEthernet0/0/0
R1(config-if)#no shutdown
R1(config-if)#interface GigabitEthernet0/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)#interface GigabitEthernet0/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)#interface GigabitEthernet0/0/0.99
R1(config-subif)#encapsulation dot1Q 99 nativeencapsulation dot1Qmust come before the IP address on a subinterface.- The physical interface needs
no shutdown; the subinterfaces follow it. The subinterface number does not have to match the VLAN, but matching it saves confusion. - The native VLAN subinterface uses the
nativekeyword so it matches the switch's untagged VLAN 99. - The switch side is a normal trunk:
switchport mode trunk, native 99, allowed 10,20,99.
Layer 3 switch SVIs and routed ports
DSW1(config)#ip routing
DSW1(config)#interface vlan 10
DSW1(config-if)#ip address 192.168.10.1 255.255.255.0
DSW1(config-if)#no shutdown
DSW1(config-if)#interface vlan 20
DSW1(config-if)#ip address 192.168.20.1 255.255.255.0
DSW1(config-if)#no shutdown
! a routed uplink to a router, no VLANs involved:
DSW1(config)#interface GigabitEthernet1/0/24
DSW1(config-if)#no switchport
DSW1(config-if)#ip address 10.0.0.1 255.255.255.252- Forget
ip routingand the SVIs come up but nothing routes between them. It is the most common mistake in this topic. - An SVI is only up/up if its VLAN exists and at least one port in that VLAN (access or trunk) is up and forwarding.
no switchportturns a switch port into a router port with its own IP, used for point to point links to routers or other Layer 3 switches.
First hop redundancy: HSRP
Every host has one default gateway address. If that router dies, the hosts are cut off even if a second router is sitting right there. A first hop redundancy protocol lets two or more routers share a virtual gateway IP and MAC, so hosts never notice which router is doing the work.
| HSRP version 1 | HSRP version 2 | |
|---|---|---|
| Groups | 0 to 255 | 0 to 4095 |
| Hellos to | 224.0.0.2, UDP 1985 | 224.0.0.102, UDP 1985 |
| Virtual MAC | 0000.0c07.acXX (XX = group) | 0000.0c9f.fXXX (XXX = group) |
| IPv6 | No | Yes |
- Highest priority becomes active (default 100; a tie goes to the highest interface IP). Hellos every 3 seconds; the standby takes over after the 10 second hold time by default.
- Preempt is off by default. Without
standby 1 preempt, a recovered primary router will not take its role back. - Alternatives: VRRP (open standard, RFC 5798, master and backup, preempt on by default) and GLBP (Cisco, shares the load across several routers at once).
R-A(config)#interface GigabitEthernet0/1
R-A(config-if)#ip address 192.168.100.2 255.255.255.0
R-A(config-if)#standby version 2
R-A(config-if)#standby 1 ip 192.168.100.1
R-A(config-if)#standby 1 priority 110
R-A(config-if)#standby 1 preempt
R-A#show standby briefPractise on R1
To keep things in one console, R1 here does both jobs: router on a stick on Gi0/0/0, and the primary HSRP router on Gi0/0/1 with a partner at 192.168.100.3 that this console models. In Packet Tracer you build them as separate parts.
Missions 0/9
Flashcards: do you remember?
Tap a card to flip it. Try to answer in your head first; recalling is what makes it stick.
Quick quiz
Instant feedback on every answer. Score 70% or more to pass this lesson's quiz.
Q1Router on a stick: what must the switch port facing the router be?
It carries several VLANs to the router.
Q2SVIs are up on a 3650 but VLAN 10 cannot reach VLAN 20. First check?
Without ip routing the switch does not route.
Q3The primary HSRP router reboots and comes back, but stays standby. Why?
Preempt is off by default.
Q4What do hosts use as their default gateway with HSRP?
The virtual IP moves between routers.
Q5Which protocol is an open standard?
VRRP, RFC 5798.
Q6Why put ACLs at the inter-VLAN gateway?
That is the internal choke point.
Hands-on lab
Packet Tracer lab 3.6: router on a stick, SVIs and HSRP
You need: Cisco Packet Tracer (free with a Cisco Networking Academy account; version 9.0.1 was the current download on the NetAcad Resource Hub when this lesson was written). Part A: 1 x ISR4331, 1 x 2960, 2 x PC. Part B: 1 x 3650, 2 x PC. Part C: 2 x 2911, 1 x 2960, 1 x PC. Reuse the VLANs from lesson 3.4.
Simulator lab, zero risk. This lab runs inside Cisco Packet Tracer, so it touches no real network. Packet Tracer is free with a Cisco Networking Academy account (netacad.com). It simulates a subset of Cisco IOS, so where support for a feature is uncertain we say so instead of promising it works.
Topology and addressing
| Device | Interface | IPv4 address / prefix | Default gateway or note |
|---|---|---|---|
| R1 (A) | Gi0/0/0.10 / .20 | 192.168.10.1/24, 192.168.20.1/24 | .99 native, no IP |
| DSW1 (B) | VLAN 10 / VLAN 20 SVIs | 192.168.10.1/24, 192.168.20.1/24 | Gi1/0/24 routed 10.0.0.1/30 |
| PCs | Fa0 | 192.168.10.11 and 192.168.20.11 | gw .1 of their VLAN |
| R-A (C) | G0/1 | 192.168.100.2/24 | HSRP active, priority 110 |
| R-B (C) | G0/1 | 192.168.100.3/24 | HSRP standby |
| PC (C) | Fa0 | 192.168.100.10/24 | gw 192.168.100.1 (virtual) |
Part A: switch side
SW1(config)#interface Gi0/1 SW1(config-if)#switchport mode trunk SW1(config-if)#switchport trunk native vlan 99 SW1(config-if)#switchport trunk allowed vlan 10,20,99Part A: router subinterfaces
R1(config)#interface Gi0/0/0 R1(config-if)#no shutdown R1(config-if)#interface Gi0/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)#interface Gi0/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)#interface Gi0/0/0.99 R1(config-subif)#encapsulation dot1Q 99 nativePing PC-Guest from PC-Staff. It should work now, which is exactly why lesson 3.9 adds an ACL.
Part B: Layer 3 switch
DSW1(config)#ip routing DSW1(config)#interface vlan 10 DSW1(config-if)#ip address 192.168.10.1 255.255.255.0 DSW1(config-if)#no shutdown DSW1(config-if)#interface vlan 20 DSW1(config-if)#ip address 192.168.20.1 255.255.255.0 DSW1(config-if)#no shutdown DSW1(config-if)#interface Gi1/0/24 DSW1(config-if)#no switchport DSW1(config-if)#ip address 10.0.0.1 255.255.255.252Then remove
ip routingand test again, to see the classic failure for yourself. Put it back.Part C: HSRP on R-A
R-A(config)#interface G0/1 R-A(config-if)#ip address 192.168.100.2 255.255.255.0 R-A(config-if)#no shutdown R-A(config-if)#standby version 2 R-A(config-if)#standby 1 ip 192.168.100.1 R-A(config-if)#standby 1 priority 110 R-A(config-if)#standby 1 preemptPart C: HSRP on R-B
R-B(config)#interface G0/1 R-B(config-if)#ip address 192.168.100.3 255.255.255.0 R-B(config-if)#no shutdown R-B(config-if)#standby version 2 R-B(config-if)#standby 1 ip 192.168.100.1 R-B(config-if)#standby 1 preemptFail over
From the PC run
ping -t 192.168.100.1, then shut R-A's G0/1. Watch R-B become active, then bring R-A back and watch it preempt. Runarp -aon the PC: the gateway's MAC is the HSRP virtual MAC, not a router's own.Verify
R1#show ip interface brief R1#show ip route DSW1#show ip route DSW1#show interfaces vlan 10 R-A#show standby brief R-A#show standby
You are done when: PCs in VLAN 10 and 20 ping each other through R1 and then through DSW1; show standby brief shows R-A Active and R-B Standby, and the roles swap and swap back when R-A's link is shut and restored.
Packet Tracer limits and notes
- Some Packet Tracer guides use
encapsulation dot1Q 99 nativeon the ISR4331; support on every image is UNVERIFIED. If rejected, leave VLAN 99 off the router. - HSRP on the Packet Tracer 3650 is UNVERIFIED, which is why Part C uses 2911 routers. VRRP and GLBP are UNVERIFIED in Packet Tracer and are theory only here.
- Cisco NetAcad publishes official Packet Tracer activities for router on a stick inter-VLAN routing if you want more practice.
- Packet Tracer simulates a subset of IOS. If a command here is rejected in your version, note it, skip that step and carry on; the concept still applies to real Cisco gear.
Download the lab checklist (.txt) Print it or keep it open beside Packet Tracer.
Key takeaways
- Every VLAN needs a gateway that routes and, ideally, filters.
- Router on a stick: dot1Q subinterfaces over one trunk.
- Layer 3 switch: ip routing plus SVIs; no switchport for routed links.
- HSRP gives hosts a virtual gateway; configure preempt deliberately.
- Authenticate FHRP hellos where you can.
Finished the sections, quiz and lab? Mark the lesson complete. Progress is saved only in this browser.