Lab Objective
Configure HSRP on two routers sharing a virtual IP address, set priority and preempt so a specific router becomes active, and verify traffic automatically fails over to the standby router when the active router goes down.
Lab Purpose
HSRP eliminates a single default gateway from being a single point of failure, discussed earlier in this series, by letting two routers share a virtual IP address that hosts use as their gateway, with one router actively forwarding while the other stands ready.
Lab Topology
R1 (intended active) ---- Gi0/1 ---- Switch1
R2 (intended standby) ---- Gi0/1 ---- Switch1
R1: 192.168.15.2/24
R2: 192.168.15.3/24
Virtual IP: 192.168.15.1/24
PC: 192.168.15.10/24, gateway 192.168.15.1Task 1: Configure Basic Addressing
Configure both routers' interfaces on the shared segment.
Task 2: Configure HSRP on Both Routers
Configure the virtual IP address on both routers using HSRP group 1.
Task 3: Configure Priority and Preempt on R1
Set R1's priority higher than the default and enable preempt so R1 becomes and remains active.
Task 4: Verify Active and Standby Roles
Confirm R1 shows as active and R2 as standby.
Task 5: Simulate a Failure and Verify Failover
Shut down R1's interface and confirm R2 automatically becomes active, then restore R1 and confirm it reclaims the active role.
Solution and Verification
R1(config)# interface gigabitethernet0/1
R1(config-if)# ip address 192.168.15.2 255.255.255.0
R1(config-if)# no shutdownR2(config)# interface gigabitethernet0/1
R2(config-if)# ip address 192.168.15.3 255.255.255.0
R2(config-if)# no shutdownR1(config)# interface gigabitethernet0/1
R1(config-if)# standby 1 ip 192.168.15.1
R1(config-if)# standby 1 priority 150
R1(config-if)# standby 1 preemptR2(config)# interface gigabitethernet0/1
R2(config-if)# standby 1 ip 192.168.15.1R1# show standby brief
Interface Grp Pri P State Active Standby Virtual IP
Gi0/1 1 150 P Active local 192.168.15.3 192.168.15.1
R2# show standby brief
Interface Grp Pri P State Active Standby Virtual IP
Gi0/1 1 100 Standby 192.168.15.2 local 192.168.15.1R1(config)# interface gigabitethernet0/1
R1(config-if)# shutdown
R2# show standby brief
Interface Grp Pri P State Active Standby Virtual IP
Gi0/1 1 100 Active local unknown 192.168.15.1
-- R2 automatically became active within
-- a few seconds of R1 going downR1(config-if)# no shutdown
R1# show standby brief
Gi0/1 1 150 P Active local 192.168.15.3 192.168.15.1
-- R1 reclaimed the active role because
-- preempt was configured and its priority
-- (150) is higher than R2's (100)Key Takeaway
Without preempt, R1 would remain standby indefinitely after recovering from its outage, even with a higher priority, since HSRP does not automatically reclaim the active role unless explicitly told to — this is the same behavior noted for Spanning Tree's root bridge election earlier in this series, and it is a detail worth double-checking whenever a "primary" device unexpectedly stays in a backup role after coming back online.