LAB: HSRP
A single default gateway is a single point of failure. In this lab two routers share a virtual IP with HSRP, a PC points at that virtual IP, and you prove the whole point of the lesson: pull the active router and the PC never notices.
- Configure HSRP on two routers: standby group, virtual IP, priority, and preempt.
- Explain why the PC uses the virtual IP, not either router's real IP.
- Verify the roles with show standby and show standby brief.
- Shut down the active router and observe the standby transition to Active.
- Confirm end-to-end connectivity survives the failover.
Overview and goal
HSRP (Hot Standby Router Protocol) is Cisco-proprietary. Both routers join HSRP group 1 and agree on the virtual IP 10.0.0.1. One router becomes Active (it answers ARP and forwards) and the other becomes Standby, sending periodic Hellos. The PC's default gateway is the virtual IP, so whichever router owns the role, the PC is happy.
To prove the gateway actually forwards traffic rather than merely saying “hello”, we add a remote network behind R2 (loopback 2.2.2.2/32) advertised into OSPF, so the PC pings across the virtual gateway to a real destination. R1 and R2 run OSPF between themselves on a transit link.
Topology
Addressing plan
| Device | Interface | IP address / mask | Role in HSRP group 1 |
|---|---|---|---|
| PC1 | NIC | 10.0.0.10 /24, gateway 10.0.0.1 | — |
| S1 | Switch | Unmanaged for the LAN 10.0.0.0/24 | — |
| R1 | GigabitEthernet 0/0 | 10.0.0.2 /24 | HSRP standby 1, priority 150, preempt → Active |
| R1 | GigabitEthernet 0/1 | 10.99.0.1 /30 | — |
| R1 | Loopback 0 | 1.1.1.1 /32 | — |
| R2 | GigabitEthernet 0/0 | 10.0.0.3 /24 | HSRP standby 1, default priority 100 → Standby |
| R2 | GigabitEthernet 0/1 | 10.99.0.2 /30 | — |
| R2 | Loopback 0 | 2.2.2.2 /32 | — |
Step 1 — Build the topology
- Add 2 routers (4321), 1 switch (2960), and 1 PC.
- PC1 → S1, R1 G0/0 → S1, R2 G0/0 → S1: copper straight-through. These all live on the 10.0.0.0/24 LAN.
- R1 G0/1 → R2 G0/1: router-to-router, so use a cross-over cable, fibre, or a serial pair with DCE clock.
Step 2 — Configure R1 (active)
Router> enable Router# configure terminal Router(config)# hostname R1 ! LAN interface with HSRP group 1 R1(config)# interface gigabitEthernet 0/0 R1(config-if)# ip address 10.0.0.2 255.255.255.0 R1(config-if)# no shutdown R1(config-if)# standby 1 ip 10.0.0.1 R1(config-if)# standby 1 priority 150 R1(config-if)# standby 1 preempt ! transit link and loopback R1(config-if)# interface gigabitEthernet 0/1 R1(config-if)# ip address 10.99.0.1 255.255.255.252 R1(config-if)# no shutdown R1(config-if)# interface loopback 0 R1(config-if)# ip address 1.1.1.1 255.255.255.255 ! OSPF so both routers know each loo R1(config-if)# end R1(config)# router ospf 1 R1(config-router)# router-id 1.1.1.1 R1(config-router)# network 10.99.0.0 0.0.0.3 area 0 R1(config-router)# network 1.1.1.1 0.0.0.0 area 0 R1(config-router)# passive-interface GigabitEthernet0/0 R1(config-router)# end
Two commands do the HSRP work: standby 1 ip 10.0.0.1 creates group 1 with the virtual IP,
and does not require group 1 to match the subnet's real addresses. standby 1
priority 150 and standby 1 preempt make R1 the preferred Active router that reclaims
the role when it is healthy. The OSPF block shares the transit link and lets the PC reach
2.2.2.2 (and R1's own 1.1.1.1) through the gateway.
Step 3 — Configure R2 (standby)
Router> enable Router# configure terminal Router(config)# hostname R2 ! LAN interface with HSRP group 1 — same virtual IP, default priority R2(config)# interface gigabitEthernet 0/0 R2(config-if)# ip address 10.0.0.3 255.255.255.0 R2(config-if)# no shutdown R2(config-if)# standby 1 ip 10.0.0.1 ! transit link and loopback R2(config-if)# interface gigabitEthernet 0/1 R2(config-if)# ip address 10.99.0.2 255.255.255.252 R2(config-if)# no shutdown R2(config-if)# interface loopback 0 R2(config-if)# ip address 2.2.2.2 255.255.255.255 R2(config-if)# end R2(config)# router ospf 1 R2(config-router)# router-id 2.2.2.2 R2(config-router)# network 10.99.0.0 0.0.0.3 area 0 R2(config-router)# network 2.2.2.2 0.0.0.0 area 0 R2(config-router)# passive-interface GigabitEthernet0/0 R2(config-router)# end
R2 gets the same standby 1 ip 10.0.0.1 (the virtual IP must match) but keeps the
default priority of 100, so it is the Standby. If R1 ever disappears, R2 seizes the virtual MAC and
becomes Active. Because its G0/1 is passive for OSPF, it did not send Hellos into the LAN toward hosts
— but it still advertises 10.0.0.0/24 into OSPF on the transit side.
Step 4 — Configure the PC
Point the PC at the virtual gateway, never at R1 or R2's real addresses:
C:\> ipconfig /ip 10.0.0.10 255.255.255.0 10.0.0.1
The PC should resolve 10.0.0.1 in its ARP cache to the virtual MAC 0000.0C07.AC01 once traffic flows. That address belongs to whichever router owns the HSRP role — which is exactly the property we are about to test.
Step 5 — Verify the HSRP roles
On both routers:
R1# show standby brief P indicates configured to preempt. Interface Grp Pri P State Active Standby Virtual IP Gi0/0 1 150 P Active local 10.0.0.3 10.0.0.1 R2# show standby brief Interface Grp Pri P State Active Standby Virtual IP Gi0/0 1 100 Standby 10.0.0.2 local 10.0.0.1
Exactly one Active, one Standby. The full show standby adds the detail we care about:
group 1, state, virtual IP and MAC, plus the timers:
R1# show standby GigabitEthernet0/0 - Group 1 State is Active 4 state changes, last state change 00:02:11 Virtual IP address is 10.0.0.1 Active virtual MAC address is 0000.0c07.ac01 Local virtual MAC address is 0000.0c07.ac01 (v1 default) Hello time 3 sec, hold time 10 sec Priority 150 (configured 150) Preemption enabled
Note the virtual MAC 0000.0c07.ac01 — group 1 encoded in the last two
hex digits — and the hello 3 s / hold 10 s timers. If HSRP is stuck in
Init or one router shows Active on both, compare priorities and the
standby 1 ip statements.
Step 6 — Baseline connectivity test
R1's G0/0 is the active gateway, and OSPF already knows both loopbacks. From the PC:
C:\> ping 10.0.0.1 Reply from 10.0.0.1: bytes=32 time=1ms TTL=255 Reply from 10.0.0.1: bytes=32 time=1ms TTL=255 Reply from 10.0.0.1: bytes=32 time=1ms TTL=255 Reply from 10.0.0.1: bytes=32 time=1ms TTL=255 C:\> ping 2.2.2.2 Reply from 2.2.2.2: bytes=32 time=1ms TTL=254 Reply from 2.2.2.2: bytes=32 time=1ms TTL=254 Reply from 2.2.2.2: bytes=32 time=1ms TTL=254 Reply from 2.2.2.2: bytes=32 time=1ms TTL=254
The TTL of 254 for 2.2.2.2 tells you the packet crossed two Layer 3 hops from the PC: PC → R1 (HSRP active) → R2 loopback. The gateway itself is one hop, hence 255. Save this baseline: after the failover the path changes but the ping must not.
Step 7 — Fail over
Kill the active gateway exactly the way a real incident would: the router dies, or at least its LAN interface disappears from the segment.
R1(config)# interface gigabitEthernet 0/0 R1(config-if)# shutdown R1(config-if)# end
Within seconds (default hold time 10 s, though a Hello will be missed immediately), R2 takes over:
R2# show standby brief Interface Grp Pri P State Active Standby Virtual IP Gi0/0 1 100 Active local unknown 10.0.0.1
R2 is now Active and answers for the virtual IP and MAC. Retest connectivity from the PC — it must not change:
C:\> ping 10.0.0.1 Reply from 10.0.0.1: bytes=32 time=1ms TTL=255 Reply from 10.0.0.1: bytes=32 time=1ms TTL=255 Reply from 10.0.0.1: bytes=32 time=2ms TTL=255 C:\> ping 2.2.2.2 Reply from 2.2.2.2: bytes=32 time=1ms TTL=254 Reply from 2.2.2.2: bytes=32 time=1ms TTL=254
The reply for 2.2.2.2 still comes back at TTL 254, but the path is different: PC → R2 (as Active gateway) → R2's loopback, which is now only one forwarding decision by a remote router after the gateway — in real life you would see the path shift to whatever upstream R2 offers. The PC never re-configured; that is HSRP working.
Restore R1 and watch it reclaim the role:
R1(config)# interface gigabitEthernet 0/0 R1(config-if)# no shutdown R1(config-if)# end R1# show standby brief Interface Grp Pri P State Active Standby Virtual IP Gi0/0 1 150 P Active local 10.0.0.3 10.0.0.1
Because R1 is configured with preempt, its higher priority (150) reclaims the Active
role without an outage. Had preempt been missing, R2 would have stayed Active forever even
though R1 was healthy again.
Step 8 — Troubleshooting guide
| Symptom | Probably | To check |
|---|---|---|
HSRP stuck in Init | The interface is down or has no IP, or the virtual IP is on the wrong interface. | show ip interface brief; the standby 1 ip statement must be on the LAN interface. |
| Both routers claim Active | They cannot hear each other's Hellos — different VLAN, or a filter dropping multicast HSRP traffic. | Confirm both in the same broadcast domain; ping real addresses; check show standby timers. |
| Standby never becomes Active on failover | HSRP group or virtual IP mismatch, or the group is configured with different parameters on each side. | show standby on both routers; group number and virtual IP must match. |
| PC cannot ping the virtual IP | Host pointing at a real router address instead of 10.0.0.1, or the switch blocks the virtual MAC (sticky/MAC security). | ipconfig on the PC; show mac address-table on S1 for 0000.0c07.ac01. |
| Higher-priority router does not become Active | preempt is missing. | Add standby 1 preempt and re-verify. |
| PC reaches gateway but not 2.2.2.2 | OSPF not enabled or the passive interface hides the wrong side. | show ip route for OSPF routes on both routers; show ip protocols. |
The vocabulary you need
Every term below appears in the lesson text above. Select one to read its definition, then use the quiz at the end to check what stuck.
Review
Check what you have learned with these review questions.
Sources & references
- Cisco. CCNA (200-301) Exam Topics. cisco.com.
- IETF. Request for Comments (RFCs). rfc-editor.org.
- IANA. Internet Assigned Numbers Authority registries. iana.org.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.