Basic HSRP Configuration

Basic HSRP Commands

Router(config-if)# standby <standby_id> ip <virtual_ip>

Assigns the interface to the standby group ID and the virtual IP address specified. The MAC address will be calculated automaticaly.

Router(config-if)# standby <standby_id> priority <prio>

Sets the priority for the interface in the specified standby group.

Router(config-if)# standby <standby_id> preempt

Enables preemption for the specified standby group ID.

Configuration Example

Topology

c2hsrp1.png

Description

In this topology, the virtual IP address will be 192.168.0.1 and the two gateways will be 192.168.0.2 and 192.168.0.3. They will both share the virtual IP address and a virtual MAC address will be generated for the standby group. Host will have 192.168.0.1 set up as its default gateway.

Router R1 will answer for the virtual IP address 192.168.0.1 and virtual MAC address 00:00:0C:07:AC:01. Whenever a host sends a packet to its default gateway, R1 will be the one to answer. If R1 fails, R2 will take over as the active router and it will be the one to answer all requests.

Configuration

The first step is creating the standby group and assigning the virtual IP address.

R1(config-if)# standby 1 ip 192.168.0.1
R2(config-if)# standby 1 ip 192.168.0.1

Usually we would like one of the routers to be preferred over the others. To accomplish this we will set the priority. For HSRP, higher is better.

R1(config-if)# standby 1 priority 200

The default priority is 100, so it is not necessary to modify it on R2.

HSRP is already configured and Host should be able to ping the virtual IP:

Host#ping 192.168.0.1
Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/24/32 ms

R1 is the current active gateway. Connecting to the virtual IP through telnet should create a session with R1.

R1#show standby
FastEthernet0/0 - Group 1
  State is Active
    2 state changes, last state change 00:06:07
  Virtual IP address is 192.168.0.1
  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 1.488 secs
  Preemption disabled
  Active router is local
  Standby router is 192.168.0.3, priority 100 (expires in 9.852 sec)
  Priority 125 (configured 125)
  IP redundancy name is "hsrp-Fa0/0-1" (default)

To verify the configuration, we will shut down f0/0 on R1. Router R2 will take over as the active gateway and a ping from Host to the virtual IP will still work.

Host#ping 192.168.0.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/24/36 ms 

R2#show standby
FastEthernet0/0 - Group 1
  State is Active
    2 state changes, last state change 00:02:07
  Virtual IP address is 192.168.0.1
  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 1.704 secs
  Preemption disabled
  Active router is local
  Standby router is unknown
  Priority 100 (default 100)
  IP redundancy name is "hsrp-Fa0/0-1" (default)

As an additional test, I configured access-lists on each router to log traffic from Host to the ip 200.200.200.1 located outside the network. This is what happens in the current state:

R2#
*Mar  1 00:51:18.303: %SEC-6-IPACCESSLOGNP: list 1 permitted 0 192.168.0.10 -> 200.200.200.1, 1 packet

Next, I will reset the f0/0 interface on R2 so that R1 will take over for it and then issue another ping. The ping should go through router R1 this time.

R1#
*Mar  1 00:53:01.459: %SEC-6-IPACCESSLOGNP: list 1 permitted 0 192.168.0.10 -> 200.200.200.1, 1 packet

HSRP logs state changes as well. After the last change, I received the following log message:

R1#
*Mar  1 00:52:55.259: %HSRP-5-STATECHANGE: FastEthernet0/0 Grp 1 state Standby -> Active

The above would have happened automatically without the need to reset the f0/0 interface on R2 if preemption were enabled. R1 would have taken over immediately because of the higher priority.
To enable preemption:

R1(config-if)# standby 1 preempt
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License