HSRP (Hot Standby Router Protocol)

Introduction

HSRP (Hot Standby Router Protocol) is a protocol developed by Cisco that allows two or more routers to work together to present the appearance of a single virtual router to the hosts on a LAN. It provides redundancy and high availability to IP networks by allowing a group of routers to share the same virtual IP address, and automatically fail over to a standby router in the event of a failure. HSRP operates at the network layer (layer 3) of the OSI model, and it is commonly used in enterprise networks to provide fault tolerance and load balancing.

HSRP Operation

HSRP works by designating one router as the active router and another as the standby router within a virtual router group. The active router is responsible for forwarding packets sent to the virtual IP address, while the standby router monitors the active router and takes over its role if it fails or becomes unreachable.

HSRP uses a virtual MAC address that is associated with the virtual IP address to identify the active router. The virtual MAC address is a multicast MAC address that begins with 00-00-0C-07-AC, followed by the HSRP group number in hexadecimal. For example, the virtual MAC address for HSRP group 1 is 00-00-0C-07-AC-01.

The active router sends periodic hello messages to the standby router to inform it of its state. The standby router monitors the hello messages and takes over as the active router if it stops receiving them. The hello messages are also used to determine the priority of each router in the group, with the router with the highest priority becoming the active router.

HSRP Priority

The priority of a router in an HSRP group can be set manually or dynamically. By default, the priority is set to 100, but this can be changed to any value between 0 and 255. The router with the highest priority becomes the active router, and if two or more routers have the same priority, the router with the highest IP address becomes the active router.

In addition to manual configuration, HSRP also supports dynamic priority, which allows a router to increase its priority automatically based on certain conditions. For example, a router can increase its priority if it has a higher bandwidth connection to the LAN or if it has a better route to a destination network.

HSRP Timers

HSRP uses several timers to determine the state of the active and standby routers. These timers include:

  • Hello timer: This timer controls the frequency at which hello messages are sent between routers. The default hello timer is 3 seconds, but it can be changed to any value between 1 and 254 seconds.
  • Hold timer: This timer controls the time that a router waits before declaring the active router as failed. The default hold timer is 10 seconds, but it can be changed to any value between 1 and 65535 seconds.
  • Active timer: This timer controls the amount of time that a router remains the active router after it stops receiving hello messages from the standby router. The default active timer is 10 seconds, but it can be changed to any value between 1 and 65535 seconds.
  • Standby timer: This timer controls the amount of time that a router remains the standby router after it receives hello messages from the active router. The default standby timer is 10 seconds, but it can be changed to any value between 1 and 65535 seconds.

HSRP States

HSRP routers can be in one of four states: initial, listen, speak, and standby.

  • Initial state: This is the starting state for a router that is joining an HSRP group. In this state, the router sends hello messages to determine the state of the active router.
  • Listen state: After the initial state, the router enters the listen state, where it listens for hello messages from the active router. The router also responds to hello messages from the standby router and updates its own HSRP state accordingly.
  • Speak state: If the router has the highest priority in the group or if it becomes the active router for any other reason, it enters the speak state. In this state, the router sends hello messages to both the active and standby routers and forwards packets sent to the virtual IP address.
  • Standby state: If the router has a lower priority than the active router or if it becomes the standby router for any other reason, it enters the standby state. In this state, the router listens for hello messages from the active router and updates its own HSRP state accordingly. If the active router fails or becomes unreachable, the standby router takes over as the active router and enters the speak state.

HSRP Versions

There are two versions of HSRP: HSRP version 1 and HSRP version 2. HSRP version 1 is the original version of the protocol, and it supports only a limited set of features. HSRP version 2 is an enhanced version of the protocol that adds support for additional features such as authentication, multiple active routers, and IPv6.

HSRP version 2 also introduces a new virtual MAC address format that begins with 00-00-5E-00-01-XX, where XX is the HSRP group number in hexadecimal. This virtual MAC address format allows for more HSRP groups to be created, as the original virtual MAC address format only supports up to 255 groups.

HSRP Authentication

HSRP version 2 supports authentication, which provides an additional layer of security for HSRP communication. Authentication can be used to prevent unauthorized routers from joining an HSRP group or to prevent rogue routers from taking over as the active router.

HSRP authentication uses a simple password-based authentication scheme, where each router in an HSRP group shares the same password. The password is stored as a clear text string on each router, and it is transmitted in plain text in HSRP hello messages.

HSRP Load Balancing

HSRP can also be used for load balancing by configuring multiple active routers in an HSRP group. This allows traffic to be distributed across multiple routers, which can help to optimize network performance and prevent bottlenecks.

However, HSRP load balancing must be used with caution, as it can also introduce additional complexity and potential points of failure. It is important to ensure that each active router in an HSRP group is configured correctly and has the capacity to handle the additional traffic.

Conclusion

HSRP is a powerful protocol that provides redundancy and high availability to IP networks. It allows multiple routers to work together to present the appearance of a single virtual router to the hosts on a LAN, and it automatically fails over to a standby router in the event of a failure. HSRP is commonly used in enterprise networks to provide fault tolerance and load balancing, and it is supported by a wide range of Cisco networking equipment.