Hot Standby Router Protocol (HSRP) is a Cisco-proprietary First Hop Redundancy Protocol (FHRP). HSRP allows two physical gateways that are configured as part of the same HSRP group to share the same virtual gateway address. Network hosts residing on the same subnet as the gateways are configured with the virtual gateway IP address as their default gateway.
While operational, the primary gateway forwards packets destined to the virtual gateway IP address of the HSRP group. In the event that the primary gateway fails, the secondary gateway assumes the role of primary and forwards all packets sent to the virtual gateway IP address. Figure 8-1 illustrates the operation of HSRP in a network.
Figure 8-1: Hot Standby Router Protocol (HSRP) Operation

Referencing Figure 8-1, HSRP is configured between the Layer 3 (Distribution Layer) switches, providing gateway redundancy for VLAN 10. The IP address assigned to the SVI on Layer 3 switch 1 is 10.10.10.2/24, and the IP address assigned to the SVI on Layer 3 switch is 10.10.10.3/24. Both switches are configured as part of the same HSRP group and share the IP address of the virtual gateway, which is 10.10.10.1.
Switch 1 has been configured with a priority of 105, while Switch 2 is using the default priority of 100. Because of the higher priority, Layer 3 switch 1 is elected the primary switch and Layer 3 switch 2 is elected as the secondary switch. All hosts on VLAN 10 are configured with a default gateway address of 10.10.10.1. Based on this solution, Switch 1 will forward all packets sent to the 10.10.10.1 address. However, in the event that Switch 1 fails, then Switch 2 will assume this responsibility. This process is entirely transparent to the network hosts.
Real World Implementation
In production networks, when configuring FHRPs, it is considered good practice to ensure that the active (primary) gateway is also the Spanning Tree Root Bridge for the particular VLAN. Referencing the diagram in Figure 8-1, for example, Switch 1 would be configured as the Root Bridge for VLAN 10 in tandem with being HSRP primary gateway for the same VLAN. This results in a deterministic network and avoids suboptimal forwarding at Layer 2 or Layer 3. For example, if Switch 2 was Root Bridge for VLAN 10, while Switch 1 was the primary gateway for VLAN 10, packets from the network hosts to the default gateway IP address would be forwarded as shown in Figure 8-2. Figure 8-2: Synchronizing the STP Topology with HSRP
![]() In the network above, packets from Host 1 to 10.10.10.1 are forwarded as follows:
|
Currently, two versions are HSRP are supported in Cisco IOS software: versions 1 and 2. The similarities and differences between the versions will be described in the sections that follow.
Hot Standby Router Protocol Version 1
By default, when Hot Standby Router Protocol is enabled in Cisco IOS software, version 1 is enabled. HSRP version 1 restricts the number of configurable HSRP groups to 255. HSRP version 1 routers communicate by sending messages to Multicast group address 224.0.0.2 using UDP port 1985. This is shown in Figure 8-3.
Figure 8-3: HSRP Version 1 Multicast Group Address

While going into detail on HSRP packet format is beyond the scope of the exam requirements, Figure 8-4 illustrates the information contained in the HSRP version 1 packet.
Figure 8-4: The HSRP Version 1 Packet Fields

In Figure 8-4, notice that the Version field shows a value of 0. This is the default value for this field when version 1 is enabled; however, remember that this implies HSRP version 1.
Hot Standby Router Protocol Version 2
HSRP version 2 uses the new Multicast address 224.0.0.102 to send Hello packets instead of the Multicast address of 224.0.0.2, which is used by version 1. The UDP port number, however, remains the same. This new address is also encoded in both the IP packet and Ethernet frame as shown in Figure 8-5.
Figure 8-5: HSRP Version 2 Multicast Group Address

While going into detail on the HSRP version 2 packet format is beyond the scope of the exam requirements, it is important to remember that HSRP version 2 does not use the same packet format as HSRP version 1.
The version 2 packet format uses a Type/Length/Value (TLV) format. HSRP version 2 packets received by an HSRP version 1 router will have the type field mapped to the version field by HSRP version 1 and subsequently ignored. Figure 8-6 illustrates the information contained in the HSRP version 2 packet.
Figure 8-6: The HSRP Version 2 Packet Fields

Hot Standby Router Protocol Version 1 and Version 2 Comparison
HSRP version 2 included enhancements to HSRP version 1. The version 2 enhancements and differences from version 1 described in the following section:
Although HSRP version 1 advertises timer values, these values are always to the whole second as it is not capable of advertising or learning millisecond timer values. Version 2 is capable of both advertising and learning millisecond timer values. Figures 8-7 and 8-8 highlight the differences between the timer fields for both HSRP version 1 and HSRP version 2, respectively.
Figure 8-7: HSRP Version 1 Timer Fields

Figure 8-8: HSRP Version 2 Timer Fields

HSRP version 1 group numbers are restricted to the range 0 to 255, whereas the version 2 group numbers have been extended from 0 to 4095. This difference will be illustrated in the configuration HSRP examples that will be provided and documented later in this chapter.
Version 2 provides improved management and troubleshooting by including a 6-byte Identifier field which is populated with the physical router interface MAC address and is used to uniquely identify the source of HSRP active Hello messages. In version 1, these messages contain the Virtual MAC address as the source MAC, which means it is not possible to determine which HSRP router actually sent the HSRP Hello message. Figure 8-9 shows the Identifier field that is present in the version 2 packet but not in the HSRP version 1 packet.
Figure 8-9: HSRP Version 2 Identifier Field

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. These differences are illustrated in Figure 8-10, which shows the version 1 virtual MAC address for HSRP group 1, as well as in Figure 8-11, which shows the version 2 virtual MAC address also for HSRP group 1.
Figure 8-10: HSRP Version 1 Virtual MAC Address Format

Figure 8-11: HSRP Version 2 Virtual MAC Address Format

Real World Implementation
