How to configure HSRP (Hot Standby Router Protocol)

Share This

HSRP is a Cisco-proprietary First Hop Redundancy Protocol (FHRP) planned to allow for transparent failover of a first-hop IPv4 device.  It allows configuring two or more routers as standby routers and only a single router as an active router at a time which ensure high network availability by providing first-hop routing redundancy for IPv4 hosts on networks configured with an IPv4 default gateway address.

All the routers in a single HSRP group share a single MAC address and IP address, which acts a default gateway to the local network. It selects an active router as well as a standby router in the group.

The active router responsible for forwarding traffic to the network and sends the hello packet to the standby router. If it fails and the Standby router don’t receive hello packet for three specific times, it takes up all the responsibilities of the active router and forwards the traffic. The HSRP configuration can be complicated at times, so this article will cover the basic points step by step. Now, look at the topology in the figure below.

HSRP

Basic HSRP Configuration

The above topology contains two HSRP routers (Router2 and Router3) both can act as the default gateway for the network 192.168.10.0/24 network. At a particular time, only one of these routers will be active with a virtual IP address of 192.168.10.1.

So, virtual IP 192.168.10.1 will be configured as the default gateway for all devices on the network 192.168.10.0/24. So let’s configure the Router1 and Router2 as HRSP router. The following configuration is enough for achieving basic HSRP configuration, the configuration on Router2 is as follow:

  • Router2>enable
  • Router2#config terminal
  • Router2(config)# interface gigabitEthernet 0/1
  • Router2(config-if)#no shutdown
  • Router2(config-if)#ip address 192.168.10.2 255.255.255.0
  • Router2(config-if)#standby 1 ip 192.168.10.1
  • Router2(config-if)#exit
  • Router2(config)#do wr

The configuration on Router3 is as follow:

  • Router3>enable
  • Router3#config terminal
  • Router3(config)# interface gigabitEthernet 0/1
  • Router3(config-if)#no shutdown
  • Router3(config-if)#ip address 192.168.10.3 255.255.255.0
  • Router3(config-if)#standby 1 ip 192.168.10.1
  • Router3(config-if)#exit
  • Router3(config)#do wr

Standby 1, 1 is the HSRP group number. This group number can be any number between 0 and 255 in HSRP version 1 and the only requirement is that you must use the same number across devices in the same HSRP group. So now we can verify the HSRP configuration using the “show standby” command.

The two figures below illustrate the output of the show standby command on Router2 and Router3. You can see the virtual IP address 192.168.10.1 on both router HSRP configuration, which is the default gateway for all the hosts in the network 192.168.10.0/24. You can also see the virtual MAC address for the virtual router.

How to configure HSRP (Hot Standby Router Protocol) 10

How to configure HSRP (Hot Standby Router Protocol) 11

You can see that Router3 is in the Active state while Router2 is on standby state. Currently, we have not configured the priority, and both routers are configured with default priority 100. So, with the same priority, the router with the highest IP address will be elected as the active router. However, we can control the configuration of the active router by configuring the priority that will be also discussed in this article.

Now the entire host will be configured with the default gateway address 192.168.10.1 and the Router3 which is currently active will receive traffic destined for the address 192.168.10.1. We have not advertised the network 192.168.10.0/24 in any routing protocol because Routes are not replicated between HSRP routers.

This means that Router1 and Router2 must individually know how to reach the 172.31.10.1 network used in our example. We have configured the default route on both routers to reach the 172.16.10.0/24 network, suppose it is the internet server, or it is your ISP. So, now if router3 is failed at any reason Router2 will start act as the active router.

HSRP Priority Configuration

HSRP the priority value can control the Active Router election. We can change the default priority value which is 100. For example, what if we wanted Router2 to be the Active router instead of Router3? To force a particular router to be the active router in an HSRP group you will need to use the priority command.

The higher priority determines the active router. If both routers are set to the same priority, the first router to come up will be the active router otherwise router with the highest IP address will be active. Let’s configure the Router priority higher then Router3, so Router2 will ever active when it is power up.

  • Router2>enable
  • Router2#config terminal
  • Router2(config)# interface gigabitEthernet 0/1
  • Router2(config-if)#standby 1 priority 110
  • Router2(config-if)#exit
  • Router2(config)#do wr

We have changed and increased the priority value of the Router2 but, it will remain in the standby mode because preemption is disabled.

HSRP Preempt

If Rouer3 fails, Router2 will become active as we have seen. But, if Router3 restore and returns to service, Router2 will continue to stay active. There are times when you may always want Router3 to be in an active state in the HSRP group.

In our case, we want Router2 as active router ever for which we increase the priority of the HRSP on the Router2. But it not changes into active mode. Cisco provides a method for users to control this by using the preempt command. Preempt ensure a router to be active after recovering from a failure.

So we want Router2 to take over the active function when it recovers from a failure, we can change our configuration on Router2 to include the standby 1 preempt command.

  • Router2>enable
  • Router2#config terminal
  • Router2(config)# interface gigabitEthernet 0/1
  • Router2(config-if)#standby 1 preempt
  • Router2(config-if)#

          %HSRP-6-STATECHANGE: GigabitEthernet0/1 Grp 1 state Standby -> Active

  • Router2(config-if)#exit
  • Router2(config)#do wr

Advanced HSRP Configuration – Load Balancing

Load Balancing is an important aspect of any network. In the above topology, one router will ever standby. This is not a good practice. To solve this problem, we can configure HSRP load balancing between routers. The load balancing is not possible in the single HSRP group, but for multiple HSRP groups, we can extend the load and have each HSRP group be active on different routers.

How to configure HSRP (Hot Standby Router Protocol) 12

For our example, let’s add Laptop0 and Laptop1 to another group (Group-2). Router2 will be active for Group1 while Router3 will be active for Group2. This means that R2 will be standby for Group2 while Router3 will be standby for Group1. The HRSP load balancing configuration is following for both routers.

The full configuration on Router2 is as follows:

  • Router2>enable
  • Router2#config terminal
  • Router2(config)# interface gigabitEthernet 0/1
  • Router2(config-if)# ip address 192.168.10.2 255.255.255.0
  • Router2(config-if)# standby 1 ip 192.168.10.1
  • Router2(config-if)#standby 1 priority 110
  • Router2(config-if)#standby 1 preempt
  • Router2(config-if)#standby 1 name Group1
  • Router2(config-if)#standby 2 ip 192.168.1.250
  • Router2(config-if)#standby 2 name Group2
  • Router2(config-if)#exit
  • Router2(config-)#exit
  • Router2#wr

The full configuration on Router3 is as follows:

  • Router3>enable
  • Router3#config terminal
  • Router3(config)# interface gigabitEthernet 0/1
  • Router3(config-if)# ip address 192.168.10.3 255.255.255.0
  • Router3(config-if)# standby 1 ip 192.168.10.1
  • Router3(config-if)#standby 1 name Group1
  • Router3(config-if)#standby 2 ip 192.168.1.250
  • Router3(config-if)#standby 2 priority 110
  • Router3(config-if)#standby 2 preempt
  • Router3(config-if)#standby 2 name Group2
  • Router3(config-if)#exit
  • Router3(config-)#exit
  • Router3#wr

This configuration allows and puts both routers in working mode. We have also configured the HSRP group name to help better describe each HSRP group. This is helpful in case of many HSRP groups.

To test this configuration, we can use the traceroute command to 172.16.10.1 from both Groups. Remember that Laptop0 and Laptop1 are in the Group2 and the default gateway for these hosts are 192.168.10.250 and the other two hosts on Group1 uses the previous Default Gateway 192.168.10.1.

(Visited 164 times, 164 visits today)
Share This