Cisco First Hop Redundancy Protocol by Tanmoy
Cisco First Hop Redundancy Protocol by Tanmoy
Explained
In every host within the organization’s network, there should be a need for a router as
the default gateway for every host to connect to the Internet. But what if the gateway
router goes offline or the default gateway IP is changed during configuration?
Replacing the gateway router will cause a longer service interruption to the users within
the organization, and that is not a reactive way to handle the issue. This is where FHRP
will take place.
To implement FHRP, there should be two or more routers that will be used as a
gateway router. The virtual IP address and virtual MAC address will be used on both the
router. The virtual IP address will be the default gateway IP address for all the devices
inside the organization’s network. One router will be used as an active router (gateway
router), and the other router will be standby. If the active router goes offline, the standby
router will take its place to be the gateway router for all the hosts.
The below diagram is an example of network topology with FHRP implemented:
Active Router– the router that actively sends and receives a packet to the host within
the organization. It is the default gateway router. Only one active router will be selected
among the cluster of routers.
Standby Router– the router/s that in case the incumbent active router will go offline,
among the standby router will be chosen as the active router.
If the active router goes offline, router failover will occur. These changes will not affect
the hosts. The host keeps the same IP address and MAC address setting. The default
gateway IP address will be the same still on all hosts. There will be no changes on the
host’s ARP table as the gateway router’s virtual MAC address will be the same.
Changes in failover only happen on router and switch, and hosts are not affected.
NOTE
Preemption in HSRP is not enabled by default. Preemption must be configured manually on the
router.
SW1 and SW2 are multilayer switches. The 192.168.1.0/24 subnet belongs to VLAN
1 and there is one host device.
There is a layer two switch in between SW1, SW2, and H1 to connect the
192.168.1.0/24 segment.
IP address 192.168.1.254 will be used for the virtual gateway address.
The multilayer switches are connected with layer three interfaces to an upstream
router called R3.
Configurations
Configurations
H1
R3
SW1
SW2
Want to try this example yourself? Here you will find the startup configuration of each
device.
The first thing we’ll do is enable HSRP. We will do this on the VLAN 1 interfaces of SW1
and SW2:
(config)#interface Vlan 1
(config-if)#standby 1 ip 192.168.1.254
Use the standby command to configure HSRP. 192.168.1.254 will be the virtual gateway IP
address. The “1” is the group number for HSRP. It doesn’t matter what you pick just make
sure it’s the same on both devices. On your console you’ll see something like this:
SW1#
Depending on which switch you configured first you’ll see these messages. One of the
switches will be the active gateway, the other one goes in standby mode. Let’s see if we
can reach this virtual gateway from our host:
R1#ping 192.168.1.254
!!!!!
As you can see we can successfully reach the virtual gateway IP address.
That wasn’t too bad right? Only one command and HSRP works! There are a couple of
other things we have to look at though. We use 192.168.1.254 as the virtual IP address but
what MAC address will it use?
You can see the MAC address of 192.168.1.254 in the ARP table, where did this MAC
address come from?
0000.0c07.ac01 is the MAC address that we have. HSRP uses the 0000.0c07.acXX MAC
address where XX is the HSRP group number. In my example I configured HSRP group
number 1. There are a couple of other interesting things to check, take a look below:
SW1#show standby
Vlan1 - Group 1
State is Standby
3 state changes, last state change 00:03:33
Preemption disabled
SW2#show standby
Vlan1 - Group 1
State is Active
Preemption disabled
Use the show standby command to verify your configuration. There’s a couple of
interesting things here:
The active router will respond to ARP requests from computers and it will be actively
forwarding packets from them. It will send hello messages to the routers that are in standby
mode. Routers in standby mode will listen to the hello messages, if they don’t receive
anything from the active router they will wait for the hold time to expire before taking over.
The hold time is 10 seconds by default which is pretty slow; we’ll see how to speed this up
in a bit.
Each HSRP router will go through a number of states before it ends up as an active or
standby router, this is what will happen:
State Explanation
This is the first state when HSRP starts. You’ll see this just after you configured HSRP or when the
Initial
interface just got enabled.
Listen The router knows the virtual IP address and will listen for hello messages from other HSRP routers.
The router will send hello messages and will join the election to see which router will become active or
Speak
standby.
The router didn’t become the active router but will keep sending hello messages. If the active router
Standby
fails it will take over.
Active The router will actively forward packets from clients and sends hello messages.
We can see all these steps with a debug command. Let’s shut the VLAN 1 interfaces first so
that we can restart HSRP:
(config)#interface Vlan 1
(config-if)#shutdown
SW1
(config)#interface Vlan 1
(config-if)#no shutdown
SW1#
HSRP: Vl1 Grp 1 Adding 0000.0c07.ac01 to MAC address filter - resetting the interface
Above you can clearly see the different states we go through before we end up in the active
state. Right now SW1 is the only switch that is running HSRP so let’s enable the VLAN 1
interface of SW2 as well:
SW2(config)#interface Vlan 1
SW2(config-if)#no shutdown
SW2#
Above we can see that SW2 is seeing 192.168.1.1 (SW1) as the active router. Eventually it
ends up in the standby state.
By default the switch with the highest priority will become the active HSRP device. If the
priority is the same then the highest IP address will be the tie-breaker. Let’s take a look at
the priorities:
The priority is the same on both switches, SW2 has a higher IP address so it should
become the active router but it’s not. Let’s try increasing its priority:
SW2(config)#interface Vlan 1
Even though SW2 has a higher priority, SW1 remains the active router. Another useful
command to verify which router is active or standby is the show standby brief command:
We can confirm SW2 has a higher priority but SW1 is still active. Once HSRP has decided
which device should be active it will stay active until it goes down. We can overrule this if
we want though…
Preemption
When we enable preemption the switch with the highest priority (or IP address in case the
priority is the same) will always become the new active device. Here’s how to enable this:
SW1 & SW2
(config)#interface Vlan 1
(config-if)#standby 1 preempt
By default preemption will take effect immediately but it might be a good idea to use a
delay. If a router or reboots it might need some time to “converge”. Maybe OSPF or EIGRP
need to form neighbor adjacencies or spanning-tree isn’t ready yet unblocking ports. If you
want to add a delay then you can do it like this:
(config)#interface Vlan 1
Authentication
HSRP also supports authentication. You can choose between plaintext or MD5
authentication. Here’s how to configure MD5:
(config)#interface Vlan 1
This ensures that all packets sent between the two switches are authenticated. This
prevents someone on the 192.168.1.0/24 subnet from joining our HSRP setup.
HSRP Timers
By default HSRP is pretty slow. SW1 is my standby router and it will wait for 10 seconds
(hold time) before it will become active once SW2 fails. That means we’ll have 10 seconds
of downtime…let’s see if we can speed that up:
SW1(config-if)#standby 1 timers ?
We can speed things up by changing the timers with the standby timers command. We
can even use millisecond values, let’s try that:
(config)#interface Vlan 1
I’ve set the hello time to 100 milliseconds and the hold timer to 300 milliseconds. Make sure
your hold time is at least three times the hello timer. Let’s verify our work:
HSRPv1 HSRPv2
Virtual MAC address 0000.0c07.acXX (XX = group number) 0000.0c9f.fxxx (XXX = group number)
(config)#interface Vlan 1
(config-if)#standby version 2
Make sure you have enabled preemption if you want to use interface tracking. Here’s an
example:
First we configure object tracking for the GigabitEthernet 0/2 interface. When the line-
protocol changes (goes down) then the object state will change.
SW2(config)#interface Vlan 1
SW2(config-if)#standby 1 track 1 ?
We can choose to decrement the priority or you can decide to shut the entire HSRP group
in case the interface is down. Let’s try decrementing the priority:
SW2(config-if)#shutdown
SW2#
You can see the priority is now 90 instead of the 150 that we configured.
You can see the priority is now 90 which is lower than SW1 (100). As a result SW2 will go to
the standby state and SW1 will move to the active state. Interface tracking is useful but it
will only check the state of the interface. It’s possible that the interface remains in the up
state but that we are unable to reach R3. It might be a better idea to use IP SLA instead
since it can check end-to-end connectivity.
SW2(config-if)#no shutdown
SW2(config)#ip sla 1
SW2(config-ip-sla)#icmp-echo 192.168.23.3
SW2(config-ip-sla-echo)#frequency 10
SW2(config)#track 1 ip sla 1
And we’ll configure SW2 once again that the priority will decrease by 60 when the object is
down:
SW2(config)#interface Vlan 1
Let’s test our configuration. First we want to make sure that IP SLA is working:
Number of successes: 7
Number of failures: 0
IP SLA is up and running. Let’s shut the GigabitEthernet 0/2 interface on SW2 again so that
IP SLA will fail:
SW2(config-if)#shutdown
Let’s check the current priority:
The priority has decreased which will cause SW1 to become the active router:
Configurations
H1
R3
SW1
SW2
Want to take a look for yourself? Here you will find the final configuration of each device.
Conclusion
You have now seen how to configure HSRP, how to enable authentication and how to
“tune” some of its parameters. I hope this has been useful. Share it with your friends and/or
colleagues. If you have any questions feel free to leave a comment in our forum.
Master Router– It is the current default gateway of all the hosts within the organization.
It is actively sending and receiving packets to the hosts.
Backup Router – The backup router will take the role of the master router during the
failover or when the master router goes offline.
NOTE
VRRPv3 supports IPv6 and is more scalable than VRRPv2.
VRRP is very similar to HSRP; if you understood HSRP you’ll have no trouble with VRRP
which is a standard protocol defined by the IETF in RFC 3768. Configuration-wise it’s
pretty much the same but there are a couple of differences.
HSRP VRRP
Different from real IP addresses on Can be the same as the real IP address
Virtual IP Address
interfaces on an interface.
Hello timer 3 seconds, hold time 10 Hello timer 1 second, hold time 3
Timers
seconds. seconds.
As you can see there are a number of differences between HSRP and VRRP. Nothing too
fancy however. HSRP is a cisco proprietary protocol so you can only use it between Cisco
devices.
Configuration
This is the topology that I will use:
SW1 and SW2 are multilayer switches and their interfaces are configured as routed ports.
We will create a virtual gateway using VRRP on the interfaces facing SW3:
SW1(config)#interface fa0/17
SW1(config-if)#vrrp 1 ip 192.168.1.3
SW2(config-if)#interface fa0/19
SW2(config-if)#vrrp 1 ip 192.168.1.3
Here’s an example how to configure VRRP. You can see the commands are pretty much
the same but I didn’t type “standby” but vrrp. I have changed the priority on SW1 to 150 and
I’ve enabled MD5 authentication on both switches.
SW1#
SW2#
You will see these messages pop-up in your console. VRRP uses different terminology than
HSRP. SW1 has the best priority and will become the master router. SW2 will become a
backup router. Let’s see what else we have:
SW1#show vrrp
FastEthernet0/17 - Group 1
State is Master
Preemption enabled
Priority is 150
SW2#show vrrp
FastEthernet0/19 - Group 1
State is Backup
Preemption enabled
Priority is 100
Use show vrrp to verify your configuration. The output looks similar to HSRP; one of the
differences is that VRRP uses another virtual MAC address:
As compared to HSRP and VRRP, Gateway Load Balancing Protocol is a bit different.
With GLBP, routers within the group are allowed to do load balancing. To put it simply,
all the traffic that is transmitted to the default gateway IP address will be load-balanced
one at a time or in a round-robin manner among the routers within the group. GLBP has
the same state as HSRP, which is called active and standby. The mechanism of
GLBP’s active and standby state is the same as HSRP’s active and standby state.
One of the key differences of GLBP is that it can do load balancing without the group
configuration that HSRP/VRRP use (what’s in a name right?).
Let’s take a look at a configuration example so you can see how this works.
Configuration
I will use the following topology to configure GLBP:
SW1 and SW2 are multilayer switches, their GigabitEthernet 0/1 interfaces are switchports
and in VLAN 1. Their interfaces that connect to R3 are routed ports. We configure SW1 and
SW2 so they create a virtual gateway for the hosts in the 192.168.1.0 /24 subnet. Let’s
enable GLBP:
SW1(config)#interface Vlan1
SW1(config-if)#glbp 1 ip 192.168.1.254
SW2(config)#interface Vlan1
SW2(config-if)#glbp 1 ip 192.168.1.254
I’ll enable GLBP on SW1 and Sw2 using the same group number (1). I changed the priority
on SW1 because I want it to be the AVG. Let’s see if this works:
Interface Grp Fwd Pri State Address Active router Standby router
Interface Grp Fwd Pri State Address Active router Standby router
Use the show glbp brief command to verify your configuration. There are a couple of
things we can see here:
• SW1 has become the AVG for group 1. SW2 (192.168.1.2) is standby for the AVG role
and will take over in case SW1 fails and group1 has two AVFs:
The virtual MAC address that GLBP uses is 0007.b400.XXYY (where X = GLBP group
number and Y = AVF number). Let’s take a look at our host, I configured it to use the
192.168.1.254 address for the default gateway.
CISCO
Introduction
This document describes how the standby preempt and standby track commands work together, and
when you must use each one.
The standby preempt command enables the Hot Standby Router Protocol (HSRP) router with the
highest priority to immediately become the active router. Priority is determined first by the configured
priority value, and then by the IP address. In each case, a higher value is of greater priority. When a
higher priority router preempts a lower priority router, the router sends a Coup message. When a
lower priority active router receives a Coup message or a Hello message from an active, higher
priority router, the router changes to the Speak state and sends a resign message.
The standby track command allows you to specify another interface on the router for the HSRP
process to monitor in order to alter the HSRP priority for a given group. If the line protocol of the
specified interface goes down, the HSRP priority is reduced. This means that another HSRP router
with higher priority can become the active router if that router has standby preempt enabled.
Prerequisites
Requirements
There are no specific requirements for this document.
Components Used
The information in this document is based on these software and hardware versions:
Cisco IOS® Software Release 12.2(10b)
Cisco 2503 Routers
The information in this document was created from the devices in a specific lab environment. All of
the devices used in this document started with a cleared (default) configuration. If your network is
live, make sure that you understand the potential impact of any command.
Conventions
Refer to Cisco Technical Tips Conventions for more information on document conventions.
Background Information
This diagram shows an example that uses the standby preempt command in conjunction with
the standby track command.
Configuration Examples
In the network diagram, HSRP is configured in this manner:
R1 is the active router and tracks the R1 serial 0 interface state. When R1 is the active router, all the traffic
from the hosts (Host 1, 2, 3) to the servers is routed through R1.
R2 is the standby router and tracks the R2 serial 1 interface state.
If the R1 serial 0 interface goes down, the R1 HSRP priority is decreased by 10. At this point the R2 HSRP
priority is higher than R1, and R2 takes over as the active router. When R2 becomes the active router, all the
traffic from the hosts to the servers is routed through R2.
Note: The default gateway for Hosts 1, 2, and 3 is configured with the HSRP virtual IP address
(171.16.6.100, in this case). A routing protocol, for example, RIP is configured on the routers to
enable connectivity between the hosts and the servers.
Here is the configuration for each router:
no ip redirects
standby 1 ip 171.16.6.100
standby 1 preempt
!--- Allows the router to become the active router when the
priority !--- is higher than all other HSRP-configured routers in
the hot standby group. !--- If you do not use the standby
preempt command in the configuration !--- for a router, that
router does not become the active router, even if !--- the priority
is higher than all other routers.
interface Serial0
ip address 171.16.2.5 255.255.255.0
interface Ethernet0
ip address 171.16.6.6 255.255.255.0
no ip redirects
standby 1 ip
!--- Indicates the hot standby group. Here the IP address of the
virtual router !--- is not configured. See the note after this table.
standby 1 preempt
!--- Allows the router to become the active router when the
priority !--- is higher than all other HSRP-configured routers in
the hot standby group. !--- If you do not use the standby
preempt command in the configuration !--- for a router, that
router does not become the active router, even if !--- the priority
is higher than all other routers.
interface Serial1
ip address 171.16.7.6 255.255.255.0
Note: R2 does not have a standby IP address configured. This is intentional in order to demonstrate
that this is a valid configuration. When R1 and R2 exchange HSRP hellos, R2 learns the standby IP
address from R1. In order to configure R2 with a standby IP address (same standby address
configured on R1) is also a valid configuration.
R1# show standby
Ethernet0 - Group 1
Local state is Active, priority 105, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.458
Virtual IP address is 171.16.6.100 configured
Active router is local
Standby router is 171.16.6.6 expires in 8.428
Virtual mac address is 0000.0c07.ac01
2 state changes, last state change 02:09:49
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 1 interface, 1 up:
Interface Decrement State
Serial0 10 Up
An HSRP priority of 120 is configured with the standby priority command and HSRP is configured to
track the state of two interfaces, Serial0 and Serial 1. Because no decrement value is specified in
the standby track command, the HSRP priority is decremented by the default value of 10 when the
tracked interface goes down. Initially, both the interfaces are up and the HSRP priority of the
interface is 120, as in the show standby command output:
R1# show standby
Ethernet0 - Group 1
Local state is Active, priority 120, may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.034
Virtual IP address is 10.0.0.5 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
2 state changes, last state change 00:00:04
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 2 interfaces, 2 up:
Interface Decrement State
Serial0 10 Up
Serial1 10 Up
R1#
Now, interface Serial 0 is brought down.
R1#
1w0d: %LINK-3-UPDOWN: Interface Serial0, changed state to down
1w0d: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed
state to down
R1#
This reduces the HSRP priority by 10—from 120 to a value of 110. You can use the show
standby command to verify this:
R1# show standby
Ethernet0 - Group 1
Local state is Active, priority 110 (confgd 120), may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 2.544
Virtual IP address is 10.0.0.5 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
2 state changes, last state change 00:00:48
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 2 interfaces, 1 up:
Interface Decrement State
Serial0 10 Down (line protocol down)
Serial1 10 Up
R1#
Next, the second tracked interface—Serial 1—is brought down:
R1#
1w0d: %LINK-3-UPDOWN: Interface Serial1, changed state to down
1w0d: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed
state to down
R1#
This again reduces the HSRP priority by 10—from 110 to a value of 100. You can use the show
standby command to verify this:
R1# show standby
Ethernet0 - Group 1
Local state is Active, priority 100 (confgd 120), may preempt
Hellotime 3 sec, holdtime 10 sec
Next hello sent in 1.846
Virtual IP address is 10.0.0.5 configured
Active router is local
Standby router is unknown
Virtual mac address is 0000.0c07.ac01
2 state changes, last state change 00:01:06
IP redundancy name is "hsrp-Et0-1" (default)
Priority tracking 2 interfaces, 0 up:
Interface Decrement State
Serial0 10 Down (line protocol down)
Serial1 10 Down (line protocol down)
R1#