How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

When high-availability isn’t a priority but a requirement, router redundancy is mandatory. As every router has its own layer 3 address, it would be useful to have the possibility to use a single layer-3 address able to “move” from a router to another. Hot Standby Router Protocol (HSRP), a proprietary protocol developed by Cisco, allows to decouple the IP addresses from the physical interfaces and to associate them to groups of interfaces, providing hardware redundancy.

Technically speaking, HSRP sends its hello message to the multicast address 224.0.0.2 (all the routers inside the network) using the 1985 UDP port, to contact the other HSRP-enabled routers and estabilish the priorities between them: the primary router – with the higher priority – will work as virtual router (with its own IP and MAC addresses) and it will be used by the hosts as gateway; in case of failure of the primary router, the router with the second highest priority will become the default gateway.

The main feature of HSRP is the ability to assign a virtual IP address to each group. If the primary router “dies”, the secondary one will take the job while the virtual IP will remain the same:

How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

We are going to see how to mirror a business gateway to assure Internet access even in case of failure of the primary router.

Let’s start the configuration by assigning the IP address to the interface fastEthernet 0/0:

  • R1#conf t
    R1(config)#interface fastEthernet 0/0
    R1(config-if)#ip address 10.0.0.252 255.255.255.0
    R1(config-if)#no shutdown
    R1#show ip interface brief
  • How to configure Hot Standby Router Protocol (HSRP) with Cisco routers
    R2#conf t
    R2(config)#interface fastEthernet 0/0
    R2(config-if)#ip address 10.0.0.253 255.255.255.0
    R2(config-if)#no shutdown
    R2#show ip interface brief

    How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

    In this example we will show a quite basic configuration:

    standby 1 10.0.0.254 (defines the virtual IP address of the group of interfaces 1)
    standby 1 priority 110 (identifies the priority of a router; default value is 100)
    standby 1 preempt (forces the highest priority router to become the Active one, insted of the currently Active router)

    Let’s configure the routers:

  • R1#conf t
    R1(config)#interface fastEthernet 0/0
    R1(config-if)standby 1 ip 10.0.0.254
    R1(config-if)standby 1 priority 110
    R1(config-if)standby 1 preempt
  • How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

  • R1#conf t
    R2(config)#interface fastEthernet 0/0
    R2(config-if)standby 1 ip 10.0.0.254
  • How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

    We can check the configuration of the HSRP group with the show standby command. The R1 router is the Acitve one while R2 is in standby.

    Analyzing the traffic we can see the routers transfering the “Hello” packets to the multicast address 224.0.0.2:

    How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

    We can now assign to a PC in the network the gateway 10.0.0.254. Launching a traceroute to the 8.8.8.8 address, you’ll see that the traffic pass through the R1 router with physical IP address 10.0.0.252, the Active one:

    How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

    By switching off the R1 router – to simulate a failure – you’ll see the R2 router become the Active one. The traffic will now pass through the R2 router, with IP address 10.0.0.253, assuring the continuity:

    How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

    How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

    Restoring the R1 router, HSRP will automatically make it Active again. In the screenshot below you can see the fastEthernet interface of R2 passing from Active to Standby:

    How to configure Hot Standby Router Protocol (HSRP) with Cisco routers

    Read related articles