Routelearn.net
Course menu

Course 10: First-Hop RedundancyLesson 1.2 (2 of 2 in this course)77 of 104 in the CCNA series

Lab: HSRP gateway failover

Configure HSRP with preempt and tracking on two routers, then predict which router forwards after each kind of failure.

Intermediate · 20 min read

After this lesson, you can configure HSRP with preempt and tracking on two routers, read show standby, and predict which router forwards after each kind of failure.

HSRP (Hot Standby Router Protocol) is a Cisco first-hop redundancy protocol in which two or more routers share a virtual IP and MAC address. One router is active and forwards traffic sent to the virtual address; a standby router takes over if the active router's Hellos stop.

In simple terms: Two routers pretend to be one gateway. If the one doing the work fails, the other carries on with the same address.

The situation

VLAN 20 (192.168.20.0/24) has two routers to the internet. Users must keep working if either router or either uplink fails. R1 has the faster uplink, so it should forward whenever it can. Both routers are addressed (R1 .2, R2 .3); HSRP isn't configured yet.

Task 1: plan it

Choose the virtual IP, the group, the version, the priorities and which routers need preempt. Then work out the virtual MAC for HSRPv2 group 20 before opening the answer.

Show the plan
SettingValueWhy
Virtual IP192.168.20.1An unused address in the subnet; it becomes every host's gateway.
Group, version20, HSRPv2Matching the VLAN number makes the group easy to recognise. Both routers must use the same.
Virtual MAC0000.0c9f.f014HSRPv2 is 0000.0c9f.fXXX with the group in hex: 20 = 0x014.
PrioritiesR1 110, R2 100 (default)The higher priority becomes active.
PreemptOn bothR1 takes the role back after it recovers; R2 can take over when tracking lowers R1's priority.
TrackingR1 tracks Gi0/1, decrement 20If R1's uplink fails, 110 − 20 = 90, below R2's 100.

Task 2: configure both routers

Show the configuration
track 1 interface GigabitEthernet0/1 line-protocol ! interface GigabitEthernet0/0 ip address 192.168.20.2 255.255.255.0 standby version 2 standby 20 ip 192.168.20.1 standby 20 priority 110 standby 20 preempt standby 20 track 1 decrement 20

R1: active while its uplink is up.

interface GigabitEthernet0/0 ip address 192.168.20.3 255.255.255.0 standby version 2 standby 20 ip 192.168.20.1 standby 20 preempt

R2: standby, default priority 100, with preempt so it can take over when R1's priority drops.

DHCP for VLAN 20 hands out default-router 192.168.20.1, the virtual IP, not .2 or .3.

Task 3: verify

Example output written for this lab, based on Cisco IOS documentation
R2#show standby brief
                     P indicates configured to preempt.
                     |
Interface   Grp  Pri P State   Active          Standby         Virtual IP
Gi0/0       20   100 P Standby 192.168.20.2    local           192.168.20.1
From R2's side: R1 (.2) is active, this router is standby, both share 192.168.20.1.
What would R1's line show?

Gi0/0 20 110 P Active local 192.168.20.3 192.168.20.1: priority 110, Active, "local" in the Active column and R2's address as standby.

Task 4: predict each failure

Pick a failure and decide which router forwards PC1's traffic before you watch. The panel shows the frame PC1 sends: its destination MAC is the virtual MAC in every case.

What fails?
Gi0/1Gi0/1PC1192.168.20.10 · GW .1SW1VLAN 20R1Gi0/0 .2 · pri 110R2Gi0/0 .3 · pri 100Internet198.51.100.10
Frame (this link)02:00:00:00:20:10 → 0000.0c9f.f014
Packet (end to end)192.168.20.10 → 198.51.100.10 · to the internet
  1. 1. R1 is active: PC1 sends to the virtual MAC, which SW1 has learned on R1's port.
  2. 2. R1 forwards: R2 hears R1's Hellos every 3 seconds and stays standby.
Hosts keep one gateway address; HSRP decides which router answers for it.

Task 5: find the fault

After a change, R2 shows:

Example output written for this lab, based on Cisco IOS documentation
R2#show standby brief
                     P indicates configured to preempt.
                     |
Interface   Grp  Pri P State   Active          Standby         Virtual IP
Gi0/0       21   100 P Active  local           unknown         192.168.20.1
R1 still shows group 20, Active.
Predict · scenario 1

From the output above, what is wrong?

Predict · scenario 2

R1 recovers after a reboot. R1 has preempt, R2 is active. What happens?