On this page
HSRP (Hot Standby Router Protocol) lets two or more routers share one virtual gateway IP address and one virtual MAC address, so hosts keep a working default gateway when the router that was forwarding for them fails. One router in the group is active and forwards traffic sent to the virtual MAC; a standby router watches its hello messages and takes over when they stop, ten seconds after the last hello with the default timers.
The protocol is Cisco's, documented in the informational RFC 2281 in 1998 and extended by Cisco as HSRP version 2. It solves the same problem as the IETF standard VRRP; the general case for first-hop redundancy, and the standard alternative, is on the VRRP and VSRP first-hop redundancy page. This page covers HSRP itself: election, timers, versions, tracking, the configuration that works and the faults that show up in production.
01 How does HSRP elect the active router?
Routers in an HSRP group exchange hello messages over UDP port 1985. Version 1 sends them to the all-routers multicast address 224.0.0.2 with a TTL of 1, so they never leave the segment. Each hello carries the sender's state, its hello time and hold time, its priority, the group number, an authentication field and the virtual IP address. Routers use their real interface address as the source, which is how they tell each other apart.
The election is simple. The router with the highest priority becomes active; if priorities are equal, the router with the higher interface IP address wins. The second best becomes standby. Every other member sits in listen and only watches. Priority is an 8-bit field, 0 to 255, and Cisco's default is 100, so two unconfigured routers decide the election on IP address alone.
RFC 2281 defines six states, and seeing them in a log tells you where a group is stuck:
- Initial: HSRP is configured but the interface has just come up or the group was just created.
- Learn: the router has no virtual IP configured and has not yet heard an authenticated hello from the active router. A router stuck here usually has the virtual address missing from its configuration.
- Listen: the router knows the virtual IP but is neither active nor standby.
- Speak: the router sends hellos and takes part in the election.
- Standby: the next in line. There is at most one standby router per group.
- Active: the router forwards packets sent to the virtual MAC and answers ARP for the virtual IP.
Only the active router uses the virtual MAC as the source of its hellos. That detail matters: it is how the switches between the routers and the hosts learn which port the virtual MAC lives on. When a new router becomes active it starts sourcing hellos from the virtual MAC and sends a gratuitous ARP, the switch tables move, and hosts never have to change their ARP entry because the MAC behind the gateway address stays the same.
02 HSRP timers, virtual MAC addresses and versions
RFC 2281 recommends a hello time of 3 seconds and a hold time of 10 seconds when nothing is configured, and says the hold time should be at least three times the hello time. The standby router declares the active router dead when the hold time expires without a hello, so default failover takes up to 10 seconds plus the time switches need to relearn the MAC. Shorter timers speed that up at the cost of more control traffic and more risk of a false failover when a busy control plane drops a hello.
The virtual MAC is derived from the group number. Version 1 uses 0000.0C07.ACxx, where xx is the group in hexadecimal, which is why version 1 groups stop at 255. Cisco's HSRP version 2 configuration guide lists what version 2 changed: group numbers 0 to 4095 so the group can match the VLAN number, a new MAC range 0000.0C9F.F000 to 0000.0C9F.FFFF, hellos sent to 224.0.0.102 instead of 224.0.0.2, millisecond timers that are advertised and learned rather than only configured locally, and a 6-byte identifier field that names the physical sender. Version 1 is still the default, and HSRP for IPv6 needs version 2.
| Property | HSRP v1 | HSRP v2 | VRRP v3 |
|---|---|---|---|
| Defined in | RFC 2281 (informational) | Cisco documentation only | RFC 5798 (standards track) |
| Group or VRID range | 0 to 255 | 0 to 4095 | 1 to 255 |
| Hello destination | 224.0.0.2, UDP 1985 | 224.0.0.102, UDP 1985 | 224.0.0.18, IP protocol 112 |
| Virtual MAC (IPv4) | 0000.0C07.ACxx | 0000.0C9F.F000 to .FFFF | 0000.5E00.01xx |
| Default hello / dead time | 3 s / 10 s | 3 s / 10 s | 1 s / about 3.6 s |
| Preemption by default | Off on Cisco IOS | Off on Cisco IOS | On |
| IPv6 | No | Yes | Yes |
| Vendors | Cisco and some clones | Cisco and some clones | Nearly all |
A v1 router and a v2 router cannot form one group: the packet formats differ and a v1 router ignores v2 hellos. Changing the version on a live group reinitialises it, because the virtual MAC changes, so plan the change for both routers in the same window.
03 Preemption, tracking and authentication
Without preemption, an active router keeps the role until it fails, even if a higher-priority router comes back online. Cisco IOS leaves preemption off by default. That is often what you want after a crash, because a router that has just booted should not grab the gateway before its routing protocols have converged. When you do want the preferred router to take the role back, configure preemption with a delay: standby 10 preempt delay minimum 60 waits 60 seconds after the interface comes up before sending the coup message that claims the role.
Tracking covers the failure HSRP cannot see by itself: an active router whose LAN interface is fine but whose uplink is dead. Tracking lowers the HSRP priority when a tracked interface or object goes down. Cisco's HSRP features TechNote says the default decrement is 10 per tracked interface, and decrements add up when several tracked interfaces fail. Two consequences follow. The decrement has to be large enough to drop the active router below its peer: with priorities 110 and 100, a decrement of 10 produces a tie at 100, and the tie goes to the higher IP address, which may be the same router. And the peer must have preemption configured, because a lower priority on the active router never moves the role unless the standby is allowed to take it.
Authentication in RFC 2281 is an 8-byte clear-text password, and the recommended default spells the word cisco. It stops a misconfigured router from joining a group by accident; it does not stop an attacker, who can read the password from any hello. Cisco IOS adds MD5 authentication with a key string or key chain, which is the setting to use on any segment where hosts you do not control can send multicast. Without it, any host on the VLAN can send a hello with priority 255 and become the default gateway for everyone.
04 How do you configure HSRP?
The shape below is Cisco IOS syntax on a Layer 3 switch with a VLAN interface. Addresses come from the 192.0.2.0/24 documentation range: the virtual gateway is 192.0.2.1, router A is 192.0.2.2 and router B is 192.0.2.3.
- Decide which router should be active for each VLAN. If the routers are also the Layer 2 distribution pair, make the HSRP active router and the spanning tree root bridge the same switch for that VLAN, so traffic does not cross the inter-switch link twice.
- Pick the version. Use version 2 on new deployments so the group number can equal the VLAN ID and IPv6 is possible later.
- Configure the interface address, the group and the virtual IP on both routers. The virtual IP must be in the interface subnet and must not be either router's own address.
- On the preferred router, raise the priority (110 is common) and enable preemption with a delay long enough for routing to converge after a reload.
- Add tracking on the preferred router with a decrement that drops it below the peer, and enable preemption on the peer so it can take over.
- Enable MD5 authentication with the same key on both routers.
- Hand the virtual IP to hosts as their default gateway, through DHCP or static configuration.
! Router A, preferred active for VLAN 10
track 1 interface GigabitEthernet0/1 line-protocol
!
interface Vlan10
ip address 192.0.2.2 255.255.255.0
standby version 2
standby 10 ip 192.0.2.1
standby 10 priority 110
standby 10 preempt delay minimum 60
standby 10 track 1 decrement 20
standby 10 authentication md5 key-string EXAMPLE-KEY
!
! Router B, standby for VLAN 10
interface Vlan10
ip address 192.0.2.3 255.255.255.0
standby version 2
standby 10 ip 192.0.2.1
standby 10 preempt
standby 10 authentication md5 key-string EXAMPLE-KEY
To share load, run a second group on another VLAN with the priorities reversed, so router B is active for VLAN 20 and router A for VLAN 10. Within one VLAN, HSRP forwards through a single active router; spreading hosts in one subnet across both routers requires two groups with two virtual IPs and two sets of hosts, which is awkward, or a different protocol such as GLBP.
05 How do you check that HSRP failover works?
Start with the summary on each router. show standby brief lists every group with its local state, priority, preemption flag, active router, standby router and virtual IP:
Router-A# show standby brief
P indicates configured to preempt.
Interface Grp Pri P State Active Standby Virtual IP
Vl10 10 110 P Active local 192.0.2.3 192.0.2.1
Router B should show the same group as Standby, with router A's address as active. If both routers claim Active, they are not hearing each other's hellos: check that the VLAN is carried on the trunk between them, that no ACL or control-plane policy drops UDP 1985 to 224.0.0.2 or 224.0.0.102, and that the version, group number and authentication key match.
Then test the failure you designed for. Shut the tracked uplink on router A and watch the log: router A's priority should fall from 110 to 90, router B should send a coup and become active within a hello interval or two, and a continuous ping from a host to an address beyond the gateway should lose no more than a few packets. Bring the uplink back and confirm router A waits out its preempt delay before taking the role back. On a host, arp -a should show the gateway address mapped to the HSRP virtual MAC, never to either router's own MAC.
06 Common HSRP mistakes
- Tracking without preemption on the peer. The active router's priority falls, but the standby never takes over because it is not allowed to preempt. Traffic keeps flowing into a router with a dead uplink.
- A decrement that only produces a tie. Priority 110 minus 10 equals the peer's 100; the higher IP address then decides, which may leave the role where it was.
- Active router and spanning tree root on different switches. Frames from hosts cross the inter-switch link to reach the gateway and come back, doubling the load on that link and hiding a bottleneck until it saturates.
- Version or group mismatch. One side on v1 and one on v2, or groups numbered differently, gives two active routers and duplicate gateways. The switch log fills with MAC moves for the virtual MAC.
- Timers set aggressively on a busy control plane. Sub-second hellos on a router whose CPU spikes during routing updates cause flaps that look like link failures.
- Clear-text or no authentication on user VLANs. Any host can win the election with priority 255 and intercept traffic.
- Mixed vendors in one group. HSRP is Cisco's protocol; most other vendors do not implement it. A Cisco and non-Cisco pair needs VRRP.
07 Where HSRP sat next to Foundry gear
Foundry's IronWare switches and routers did not run HSRP. Foundry built its first-hop redundancy on standard VRRP and its own VRRP-E extension, which dropped the address-owner concept so either router could be master, plus VSRP for Layer 2 redundancy. Networks that mixed Cisco and Foundry routers on the same subnet therefore ran VRRP on both, and migrations from Cisco to NetIron or BigIron routers usually meant converting HSRP groups to VRRP. The conversion is mechanical: the group number becomes the VRID, the priority and preemption settings carry over, and the hosts never notice, because the virtual IP stays the same while only the virtual MAC changes. Send a gratuitous ARP or wait for host ARP caches to expire, and plan the cutover per VLAN. Where the gateway pair sits in the larger design, and why the distribution layer rather than the core router layer usually owns it, is covered with the rest of the routing topics in the routing guide index.
08 Questions
What is the difference between HSRP and VRRP?
Both give hosts a virtual default gateway. HSRP is Cisco's protocol, documented in informational RFC 2281, with a 3 second hello and preemption off by default on IOS. VRRP is the IETF standard (RFC 5798), with a 1 second advertisement, preemption on by default and support from nearly every vendor. Use VRRP when the routers come from different vendors.
What is the HSRP virtual MAC address?
For version 1 it is 0000.0C07.ACxx, where xx is the group number in hexadecimal. Version 2 uses the range 0000.0C9F.F000 to 0000.0C9F.FFFF, which covers groups 0 to 4095. The active router answers ARP for the virtual IP with this MAC.
How long does HSRP failover take?
With default timers the standby declares the active router down when the 10 second hold time expires without a hello, so failover takes up to about 10 seconds plus switch MAC relearning. Shorter hello and hold timers, including millisecond timers in version 2, reduce that at the cost of more control traffic.
Why does HSRP tracking not move the active role?
Usually because the standby router has no preemption configured, so it never claims the role even when its priority is higher. The other common cause is a decrement that only brings the active router level with its peer, leaving the tie to the higher interface IP address.
Can HSRP version 1 and version 2 routers share a group?
No. The packet formats differ and a version 1 router ignores version 2 hellos, so both routers become active. Change the version on both routers in the same maintenance window; the group reinitialises because its virtual MAC changes.
Does HSRP support IPv6?
Yes, but only HSRP version 2. IPv6 groups advertise a link-local virtual address that hosts learn through router advertisements, and the same priority, preemption and tracking rules apply as for IPv4 groups.