Hot Standby Router Protocol Primary Gateway Election
HSRP primary gateway election can be influenced by adjusting the default HSRP priority of 100 to any value between 1 and 255. The router with the highest priority will be elected as the primary gateway for the HSRP group.
If two gateways are using the default priority values, or if the priority values on two gateways are manually configured as equal, the router with the highest IP address will be elected as the primary gateway. The HSRP priority value is carried in the HSRP frame, as is the current state of the router, e.g. primary or standby. Figure 8-12 illustrates the priority and state fields of a gateway configured with a non-default priority value of 105, which resulted in it being elected as active gateway for the HSRP group.
Figure 8-12: HSRP Priority and State Fields

Hot Standby Router Protocol Messages
HSRP routers exchange three types of messages:
- Hello Messages
- Coup Messages
- Resign Messages
Hello messages are exchanged via Multicast and tell the other gateway the HSRP state and priority values of the local router. Hello messages also include the Group ID, HSRP timer values, version, and authentication information. All of the messages shown in the previous messages are HSRP Hello messages.
HSRP Coup messages are sent when the current standby router wants to assume the role of active gateway for the HSRP group. This is similar to a coup d’état in real life.
HSRP Resign messages are sent by the active router when it is about to shut down or when a gateway that has a higher priority sends a Hello or Coup message. In other words, this message is sent when the active gateway concedes its role as primary gateway.
HSRP Preemption
If a gateway has been elected active gateway and another gateway that is part of the HSRP group is reconfigured with a higher priority value, the current active gateway still retains the primary forwarding role. This is the default behavior of HSRP.
In order for a gateway with a higher priority to assume active gateway functionality when a primary gateway is already present for an HSRP group, the router must be configured for preemption. This allows the gateway to initiate a coup and assume role of the active gateway for the HSRP group. HSRP preemption is illustrated in the configuration examples.
NOTE: Preemption does not necessarily mean that the Spanning Tree topology changes also.
Hot Standby Router Protocol States
In a manner similar to OSPF, when HSRP is enabled on an interface, the gateway interface goes through a series of states. These states are:
- Disabled
- Init
- Listen
- Speak
- Standby
- Active
NOTE: There are no set time values for these interface transitions.
In either the disabled or init states, the gateway is not yet ready or is unable to participate in HSRP, possibly because the associated interface is not up.
The listen state is applicable to the standby gateway. Only the standby gateway monitors Hello messages from the active gateway. If the standby gateway does not receive Hellos within 10 seconds, it assumes that the active gateway is down and assumes this role itself. If other gateways exist on the same segment, they also listen to Hellos and will be elected as the group active gateway if they have the next highest priority value or IP address.
During the speak phase, the standby gateway exchanges messages with the active gateway. Upon completion of this phase, the primary gateway transitions to the active state, and the backup gateway transitions to the standby state. The standby state indicates that the gateway is ready to assume the role of active gateway if the primary gateway fails, and the active state indicates that the gateway is ready to actively forward packets.
Example 8-1 shows the state transitions displayed in the output of the debug standby command on a gateway for which HSRP has just been enabled.
Example 8-1: HSRP State Transitions
| R2#debug standby HSRP debugging is on R2# R2# R2# R2#conf Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. R2(config)#logging con R2(config)#int f0/0 R2(config-if)#stand 1 ip 192.168.1.254 R2(config-if)# R2(config-if)# R2(config-if)# R2(config-if)# *Mar 1 01:21:55.471: HSRP: Fa0/0 API 192.168.1.254 is not an HSRP address *Mar 1 01:21:55.471: HSRP: Fa0/0 Grp 1 Disabled -> Init *Mar 1 01:21:55.471: HSRP: Fa0/0 Grp 1 Redundancy “hsrp-Fa0/0-1” state Disabled -> Init *Mar 1 01:22:05.475: HSRP: Fa0/0 Interface up … [Truncated Output] … *Mar 1 01:22:06.477: HSRP: Fa0/0 Interface min delay expired *Mar 1 01:22:06.477: HSRP: Fa0/0 Grp 1 Init: a/HSRP enabled *Mar 1 01:22:06.477: HSRP: Fa0/0 Grp 1 Init -> Listen *Mar 1 01:22:06.477: HSRP: Fa0/0 Redirect adv out, Passive, active 0 passive 1 … [Truncated Output] … *Mar 1 01:22:16.477: HSRP: Fa0/0 Grp 1 Listen: d/Standby timer expired (unknown) *Mar 1 01:22:16.477: HSRP: Fa0/0 Grp 1 Listen -> Speak … [Truncated Output] … *Mar 1 01:22:26.478: HSRP: Fa0/0 Grp 1 Standby router is local *Mar 1 01:22:26.478: HSRP: Fa0/0 Grp 1 Speak -> Standby *Mar 1 01:22:26.478: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Speak -> Standby *Mar 1 01:22:26.478: HSRP: Fa0/0 Grp 1 Redundancy “hsrp-Fa0/0-1” state Speak -> Standby |
HSRP Addressing
Earlier in this chapter, we learned that in HSRP version 1, the Layer 2 address that is used by the virtual IP address will be a virtual MAC address composed of 0000.0C07.ACxx, where ‘xx‘ is the HSRP group number in Hexadecimal value and based on the respective interface. HSRP version 2, however, uses a new MAC address range 0000.0C9F.F000 to 0000.0C9F.FFFF for the virtual gateway IP address.
In some cases, it may not be desirable to use these default address ranges. An example would be a situation where several HSRP groups were configured on a router interface connected to a switch port that was configured for port security. In such a case, the router would use a different MAC address for each HSRP group, the result being multiple MAC addresses which would all need to be accommodated in the port security configuration. This configuration would have to be modified each time an HSRP group was added to the interface, otherwise, a port security violation would occur.
To address this issue, Cisco IOS software allows administrators to configure HSRP to use the actual MAC address of the physical interface on which it is configured. The result is that a single MAC address is used by all groups (the MAC address of the active gateway is used) and the port security configuration need not be modified each time an HSRP group is configured between the routers connected to the switches. This is performed via thestandby use-bia interface configuration command. Example 8-2 shows the output of the show standby command which shows a gateway interface that is configured with two different HSRP groups.
Example 8-2: Verifying Default HSRP Addressing
| Gateway-1#show standby FastEthernet0/0 – Group 1 State is Active 8 state changes, last state change 00:13:07 Virtual IP address is 192.168.1.254 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 Next hello sent in 2.002 secs Preemption disabled Active router is local Standby router is 192.168.1.2, priority 100 (expires in 9.019 sec) Priority 105 (configured 105) IP redundancy name is “hsrp-Fa0/0-1” (default) FastEthernet0/0 – Group 2 State is Active 2 state changes, last state change 00:09:45 Virtual IP address is 172.16.1.254 Active virtual MAC address is 0000.0c07.ac02 Local virtual MAC address is 0000.0c07.ac02 (v1 default) Hello time 3 sec, hold time 10 sec Next hello sent in 2.423 secs Preemption disabled Active router is local |
In the output above, based on the default HSRP version, the virtual MAC address for HSRP group 1 is 0000.0c07.ac01, while that for HSRP group 2 is 0000.0c07.ac02. This means that the switch port that this gateway is connected to learns three different addresses: the actual or burned in MAC address assigned to the actual physical FastEthernet0/0 interface, the virtual MAC address for HSRP group 1 and the virtual MAC address for HSRP group 2.
Example 8-3 illustrates how to configure HSRP to use the actual MAC address of the gateway interface as the virtual MAC address of the different HSRP groups.
Example 8-3: Configuring the Gateway to use the Interface BIA
| Gateway-1#conf Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Gateway-1(config)#int f0/0 Gateway-1(config-if)#standby use-bia Gateway-1(config-if)#exit |
Based on the configuration in Example 8-3, the show standby command reflects the new MAC address for the HSRP group as illustrated in Example 8-4.
Example 8-4: Verifying Default HSRP BIA Addressing
| Gateway-1#show standby FastEthernet0/0 – Group 1 State is Active 8 state changes, last state change 00:13:30 Virtual IP address is 192.168.1.254 Active virtual MAC address is 0013.1986.0a20 Local virtual MAC address is 0013.1986.0a20 (bia) Hello time 3 sec, hold time 10 sec Next hello sent in 2.756 secs Preemption disabled Active router is local Standby router is 192.168.1.2, priority 100 (expires in 9.796 sec) Priority 105 (configured 105) IP redundancy name is “hsrp-Fa0/0-1” (default) FastEthernet0/0 – Group 2 State is Active 2 state changes, last state change 00:10:09 Virtual IP address is 172.16.1.254 Active virtual MAC address is 0013.1986.0a20 Local virtual MAC address is 0013.1986.0a20 (bia) Hello time 3 sec, hold time 10 sec Next hello sent in 0.188 secs Preemption disabled Active router is local Standby router is unknown Priority 105 (configured 105) IP redundancy name is “hsrp-Fa0/0-2” (default) |
The MAC address used by both groups, 0013.1986.0a20, is the MAC address assigned to the physical gateway interface. This is illustrated in Example 8-5.
Example 8-5: Verifying the Interface MAC Address
| Gateway-1#show interface fastethernet 0/0 FastEthernet0/0 is up, line protocol is up Hardware is AmdFE, address is 0013.1986.0a20 (bia 0013.1986.0a20) Internet address is 192.168.1.1/24 MTU 1500 bytes, BW 100000 Kbit/sec, DLY 100 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set … [Truncated Output] |
NOTE: In addition to configuring HSRP to use the BIA, administrators also have the option of statically specifying the MAC address that the virtual gateway should use via the standby [number] mac-address [mac] interface configuration command. This option is typically avoided as it can result in duplicate MAC addresses in the switched network, which can cause severe network issues, and possibly event an outage.
HSRP Plain Text Authentication
By default, HSRP messages are sent with the plain-text key string ‘cisco’, as a simple method to authenticate HSRP peers. If the key string in a message matches the key configured on an HSRP
peer, the message is accepted. If not, HSRP ignores the unauthenticated message(s).
Plain text keys provide very little security because they can be ‘captured on the wire’ using simple packet capture tools, such as Wireshark and Ethereal. Figure 8-13 shows the default plain-text authentication key used in HSRP messages.
Figure 8-13: Viewing the Default HSRP Plain-Text Key

Because plain-text authentication provides very little security, MD5 authentication, which is described in the following section, is the recommended authentication method for HSRP.
HSRP MD5 Authentication
Message Digest 5 authentication provides greater security for HSRP than that provided by plain text authentication by generating an MD5 digest for the HSRP portion of the Multicast HSRP protocol packet. Using MD5 authentication allows each HSRP group member to use a secret key to generate a keyed MD5 hash that is part of the outgoing packet. A keyed hash of the incoming HSRP packet is generated and if the hash within the incoming packet does not match the MD5 generated hash, the packet is simply ignored by the receiving router.
The key for the MD5 hash can be either given directly in the configuration using a key string or supplied indirectly through a key chain. Both configuration options will be described in detail later in this chapter. When using plain-text or MD5 authentication, the gateway will reject HSRP packets if any of the following is true:
- If the authentication schemes differ on the router and in the incoming packets
- If the MD5 digests differ on the router and in the incoming packet
- If the text authentication strings differ on the router and in the incoming packet