Learn / Stage 3: Networking and CCNA / Lesson 3.6

$ lesson 3.6 --track ccna --domain routing

Inter-VLAN Routing and First Hop Redundancy: Router on a Stick, SVIs, HSRP

VLANs keep groups apart; routing lets them talk on your terms. Learn the two real ways to route between VLANs, why the default gateway is a single point of failure, and how HSRP fixes it without anyone changing a setting on their laptop.

  • Stage 3 Networking and CCNA
  • Level Intermediate
  • 60 min
  • 5 sections, quiz, lab

Start the lesson Jump to the lab

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
3.6.01

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.

Inter-VLAN routing methods
MethodHowGood forWatch out
LegacyOne router interface per VLANTeaching onlyBurns router ports and switch ports.
Router on a stickOne trunk to a router, one subinterface per VLANSmall sites, labsAll inter-VLAN traffic shares one physical link.
Layer 3 switchip routing plus an SVI per VLANMost campus networksRouting happens in switch hardware at full speed; filter it with ACLs.
3.6.02

Router on a stick

Router on a stick: one trunk from SW1 to R1 carries VLANs 10, 20 and 99 to subinterfacesGi0/0/0 .10 .20 .99Gi0/1 trunkFa0/1 VLAN 10Fa0/11 VLAN 20R1ISR4331SW1PC-Staff192.168.10.11PC-Guest192.168.20.11
SW1's Gi0/1 is an 802.1Q trunk. R1 receives tagged frames on Gi0/0/0 and hands each VLAN to its own subinterface.
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 native
  • encapsulation dot1Q must 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 native keyword 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.
3.6.03

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 routing and 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 switchport turns a switch port into a router port with its own IP, used for point to point links to routers or other Layer 3 switches.
3.6.04

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: two routers share a virtual gateway IP. The active router answers for it; the standby takes over if hellos stopR-A Activereal .2, priority 110R-B Standbyreal .3, priority 100Hostsgateway 192.168.100.1hellosvirtual IP .1 and virtual MAC live on the active router
Hosts use 192.168.100.1, which belongs to no physical router. The active router answers ARP for it with the HSRP virtual MAC.
HSRP versions
HSRP version 1HSRP version 2
Groups0 to 2550 to 4095
Hellos to224.0.0.2, UDP 1985224.0.0.102, UDP 1985
Virtual MAC0000.0c07.acXX (XX = group)0000.0c9f.fXXX (XXX = group)
IPv6NoYes
  • 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 brief
3.6.05

Practise 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.

console: R1 (R1 inter-VLAN and HSRP)

Missions 0/9

    Simplified IOS simulator in your browser. It teaches the commands; Packet Tracer and real gear have many more.

    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?

    Q2SVIs are up on a 3650 but VLAN 10 cannot reach VLAN 20. First check?

    Q3The primary HSRP router reboots and comes back, but stays standby. Why?

    Q4What do hosts use as their default gateway with HSRP?

    Q5Which protocol is an open standard?

    Q6Why put ACLs at the inter-VLAN gateway?

    0 / 6

    Hands-on lab

    Cisco Packet Tracer lab60 minutessimulated network

    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.

    Topology and addressing

    Router on a stick: one trunk from SW1 to R1 carries VLANs 10, 20 and 99 to subinterfacesGi0/0/0 .10 .20 .99Gi0/1 trunkFa0/1 VLAN 10Fa0/11 VLAN 20R1ISR4331SW1PC-Staff192.168.10.11PC-Guest192.168.20.11
    Part A shown: R1 Gi0/0/0 to SW1 Gi0/1 (trunk), PC-Staff on Fa0/1 (VLAN 10), PC-Guest on Fa0/11 (VLAN 20). Part B replaces R1 and SW1 with one 3650. Part C puts two 2911s on one switch in 192.168.100.0/24.
    Addressing table
    DeviceInterfaceIPv4 address / prefixDefault gateway or note
    R1 (A)Gi0/0/0.10 / .20192.168.10.1/24, 192.168.20.1/24.99 native, no IP
    DSW1 (B)VLAN 10 / VLAN 20 SVIs192.168.10.1/24, 192.168.20.1/24Gi1/0/24 routed 10.0.0.1/30
    PCsFa0192.168.10.11 and 192.168.20.11gw .1 of their VLAN
    R-A (C)G0/1192.168.100.2/24HSRP active, priority 110
    R-B (C)G0/1192.168.100.3/24HSRP standby
    PC (C)Fa0192.168.100.10/24gw 192.168.100.1 (virtual)
    1. 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,99
    2. Part 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 native

      Ping PC-Guest from PC-Staff. It should work now, which is exactly why lesson 3.9 adds an ACL.

    3. 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.252

      Then remove ip routing and test again, to see the classic failure for yourself. Put it back.

    4. 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 preempt
    5. Part 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 preempt
    6. Fail 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. Run arp -a on the PC: the gateway's MAC is the HSRP virtual MAC, not a router's own.

    7. 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 native on 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.