Hot Standby Router Protocol (HSRP)

How Cisco routers share a default gateway address and transfer its forwarding role after a failure.

One virtual gateway, one active router per group

Hosts use the HSRP virtual IP address as their default gateway. In the usual virtual-MAC configuration, the active router answers ARP for the virtual IP with the group’s virtual MAC and forwards traffic sent to it. The standby router can assume that role, so hosts keep the same default gateway address.

The initial election prefers the highest configured priority, with the higher interface IP address as a tie-breaker. A higher-priority router can displace an existing active router when preemption is enabled. Tracking can lower a router’s effective priority when a monitored uplink fails.

Failover transfers the virtual MAC

If the standby stops hearing the active router’s hellos, it can take over when the hold timer expires. The virtual MAC moves to the new active router. A switch can relearn the MAC on a different port while hosts retain the same IP-to-MAC mapping for their gateway.

HSRP versions use different virtual MAC ranges. For example, IPv4 group 1 normally uses 0000.0c07.ac01 in HSRPv1 or 0000.0c9f.f001 in HSRPv2. Configure a matching version on both routers.

Try it in a lab

  1. Connect two HSRP-capable routers and a host to the same switch and VLAN. Give the routers 10.0.0.1/24 and 10.0.0.2/24, configure group 1 with virtual IP 10.0.0.254, and give the first router the higher priority. Configure the host to use the virtual IP as its gateway.
  2. Confirm the active and standby roles, ping the virtual IP from the host, and note its ARP entry. In the lab, shut the active router’s LAN interface while leaving the switch and standby link up.
  3. After the standby takes over, verify that it answers for 10.0.0.254 and that the host still resolves the same virtual MAC. Where both routers have working upstream paths, check that routed traffic resumes too.

Sources