HSRP is a protocol that helps to achieve the failover. With the help of HSRP, we can configure active and standby routers and that goal is achieved with the help of a virtual IP. When active goes down, the standby router comes to the rescue. Let us understand the Cisco HSRP Configuration.
Given below is the topology that will help us understand the HSRP configuration.
R1 is configured with 192.168.1.1 and R2 is configured with 192.168.1.2.
192.168.1.254 is the virtual IP.
R1(config)#interface GigabitEthernet0/0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#standby 1 ip 192.168.1.254
R1(config-if)#exit
%HSRP-6-STATECHANGE: GigabitEthernet0/0/0 Grp 1 state Standby -> Standby
This message will pop up.
R1 is now a standby router.
Why so?
Since we have not configured any priority, and the default priority is 100. So the router with a lesser IP Address becomes the standby while the router with a Higher IP address becomes an Active router.
Let's configure R2.
R2(config)#interface GigabitEthernet0/0/1
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#standby 1 ip 192.168.1.254
R2(config-if)#exit
%HSRP-6-STATECHANGE: GigabitEthernet0/0/1 Grp 1 state Standby -> Active
R2 becomes an active router since priority is 100 which is default but it has a Higher IP Address.
Verification
R1#show standby
GigabitEthernet0/0/0 – Group 1
State is Standby
8 state changes, last state change 00:18:38
Virtual IP address is 192.168.1.254
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.285 secs
Preemption disabled
Active router is 192.168.1.2
Standby router is local
Priority 100 (default 100)
Group name is hsrp-Gig0/0/0-1 (default)
R2#show standby
GigabitEthernet0/0/1 – Group 1
State is Active
5 state changes, last state change 00:05:14
Virtual IP address is 192.168.1.254
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 0 secs
Preemption disabled
Active router is local
Standby router is 192.168.1.1
Priority 100 (default 100)
Group name is hsrp-Gig0/0/1-1 (default)
Let us configure the priority value and make R1 an Active Router.
R1(config)#interface GigabitEthernet0/0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)# standby 1 ip 192.168.1.254
R1(config-if)# standby 1 priority 110
R1(config-if)# standby 1 preempt
%HSRP-6-STATECHANGE: GigabitEthernet0/0/0 Grp 1 state Speak -> Standby
%HSRP-6-STATECHANGE: GigabitEthernet0/0/0 Grp 1 state Standby -> Active
R1 goes from standby to Active since priority is set to 110 which is higher than default priority configured on R2 i.e. 100
R2(config)#interface GigabitEthernet0/0/1
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#standby 1 ip 192.168.1.254
R2(config-if)# standby 1 priority 100
%HSRP-6-STATECHANGE: GigabitEthernet0/0/1 Grp 1 state Speak -> Standby
The “preempt” here in HSRP is used to specify that a router with a higher priority should automatically take back the role of the active (primary) router when it becomes available again after a failure.
Verification
R1#show standby
GigabitEthernet0/0/0 – Group 1
State is Active
5 state changes, last state change 00:02:11
Virtual IP address is 192.168.1.254
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.966 secs
Preemption enabled
Active router is local
Standby router is 192.168.1.2
Priority 110 (configured 110)
Group name is hsrp-Gig0/0/0-1 (default)
R2#show standby
GigabitEthernet0/0/1 – Group 1
State is Standby
3 state changes, last state change 00:02:29
Virtual IP address is 192.168.1.254
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 0.992 secs
Preemption disabled
Active router is 192.168.1.1
Standby router is localbl
Priority 100 (default 100)
Group name is hsrp-Gig0/0/1-1 (default)