Cisco HSRP Configuration: Priority, Preempt and Track - 夜莺博客

Cisco HSRP Configuration: Priority, Preempt and Track

Hot Standby Router Protocol (HSRP) gives an IP subnet a virtual default gateway that is served by two real routers, so a single router failure does not strand the hosts. The protocol elects one active router and one standby from a group, and the election is controlled by priority, preemption and interface tracking. This article builds a two-router HSRP pair with an uplink-tracking failover policy and shows exactly what happens in the output when the active router loses its upstream.

HSRP Election Basics

Every router in the group gets a priority from 1 to 255 (default 100); the highest priority becomes active. preempt lets a router reclaim the active role when its priority becomes highest again — without it, the first router to come up stays active forever. Tracking lowers a router's priority when a monitored object (usually an uplink interface) goes down, which hands the gateway to the healthy peer.

Full Configuration Example

R1 is the preferred active router: virtual IP 172.16.6.100 in group 1, priority 105, preempt enabled, and it tracks its server-facing uplink FortyGigabitEthernet0/2/4 with a decrement of 10. When that uplink drops, R1's priority falls to 95 and R2 takes over:

R1# configure terminal
R1(config)# track 10 interface FortyGigabitEthernet0/2/4 line-protocol
R1(config-track)# exit
R1(config)# interface FortyGigabitEthernet0/2/0
R1(config-if)# ip address 172.16.6.5 255.255.255.0
R1(config-if)# standby 1 ip 172.16.6.100
R1(config-if)# standby 1 priority 105
R1(config-if)# standby 1 preempt
R1(config-if)# standby 1 track 10 decrement 10
R1(config-if)# end
R2# configure terminal
R2(config)# track 20 interface FortyGigabitEthernet0/2/4 line-protocol
R2(config-track)# exit
R2(config)# interface FortyGigabitEthernet0/2/0
R2(config-if)# ip address 172.16.6.6 255.255.255.0
R2(config-if)# standby 1 ip 172.16.6.100
R2(config-if)# standby 1 preempt
R2(config-if)# standby 1 track 20 decrement 10
R2(config-if)# end

R2 keeps the default priority 100, so it is the standby while R1 is healthy, and it takes over the moment R1's tracked uplink fails and its priority drops to 95.

Verification

show standby brief
show standby
show track brief

Healthy state: active router 172.16.6.5 (R1, priority 105), standby 172.16.6.6 (R2, priority 100). After the tracked uplink on R1 fails, R1's priority shows 95 (configured 105), the track object reports Down with decrement 10, and R2 becomes the active router because preemption is enabled on both sides. When the uplink recovers, R1 preempts back to active. For multiple tracked objects, each gets its own decrement value and they add up — the Cisco example shows two tracks decrementing 10 and 20 for a combined drop to 75.

Design Notes

  • Always enable preempt on both routers or failback after a repair will not happen automatically.
  • Track the path, not just the local interface: combine interface tracking with track ip route when the failure is beyond the first hop.
  • Hello/hold timers default to 3/10 seconds; on Catalyst switches use the same group ID and virtual IP on both members of an access pair.
  • HSRP answers ARP for the virtual IP, so hosts keep one static default gateway — this complements rather than replaces routing redundancy such as MLAG with a VARP/VRRP gateway at the access layer.

For related first-hop redundancy on Nexus, see our Nexus vPC failover troubleshooting article, and the campus access design in Cisco inter-VLAN routing.

原文链接:https://www.cisco.com/c/en/us/support/docs/ip/hot-standby-router-protocol-hsrp/13780-6.html