Lesson Contents
HSRP Object Tracking Interface monitors the operational state of a specific interface and automatically adjusts the priority of a Hot Standby Router Protocol (HSRP) router when that interface goes down, triggering a failover to the standby router. This is useful because without it, it’s possible that your router has no upstream path but remains the active default gateway while another router still has a working upstream link.
In this lesson, you’ll learn how to configure object tracking on an upstream interface and link it to an HSRP group with a priority decrement. We’ll configure object tracking, associate it with an HSRP group, simulate an interface failure, and verify the automatic failover to another HSRP router.
Key Takeaways
- HSRP object tracking monitors the state of a specific interface and automatically adjusts router priority when the tracked interface fails, triggering failover without requiring manual intervention.
- Create a track object with
track <number> interface <interface> line-protocolto monitor whether an interface’s line-protocol is up or down. - Associate a track object to an HSRP group using
standby <group> track <number> decrement <value>, which reduces the router’s priority by the specified amount when the tracked object fails. - Both the active and standby routers should have the same track object configured so they monitor the same conditions and can respond appropriately to network changes. It’s not a requirement but a best practice.
- When a tracked interface goes down, the router’s priority is automatically decremented; if this causes the active router’s priority to drop below the standby router’s priority, the standby router becomes active (assuming preemption is enabled).
- Verify track object status with
show trackto confirm the object is monitoring the correct interface and displays which HSRP groups are tracking it. - Use
show standbyto display detailed HSRP state, including the current track object status and whether a priority decrement is active for each group.
Prerequisites
You should understand HSRP Basic Configuration, including how to configure standby groups and virtual IP addresses. It can be useful to understand HSRP preemption because we use it in this lesson. Object tracking is not too difficult so you’ll learn it as we go through this lesson.
Configuration
Here’s the topology we’ll use for this lab:
Here’s what we have:
- R1 and R2 are routers that will run HSRP:
- R1 is the primary router with priority 110.
- R2 is the standby router with priority 105.
- We’ll run HSRP on the 192.168.12.0/24 subnet.
R3 is an upstream router on the 192.168.123.0/24 segment if you want to test reaching something upstream.
Configurations
Want to take a look for yourself? Here you will find the startup configuration of each device.
R1
hostname R1
!
ip cef
!
interface Ethernet0/1
ip address 192.168.12.1 255.255.255.0
!
interface Ethernet0/2
ip address 192.168.123.1 255.255.255.0
!
end
R2
hostname R2
!
ip cef
!
interface Ethernet0/1
ip address 192.168.12.2 255.255.255.0
!
interface Ethernet0/2
ip address 192.168.123.2 255.255.255.0
!
end
R3
hostname R3
!
ip cef
!
interface Ethernet0/1
ip address 192.168.123.3 255.255.255.0
!
end
Track Object for Interface Line-Protocol State
Object tracking lets HSRP react to network changes. When an interface goes down, the track object immediately detects the change and notifies HSRP to adjust its behavior. We’ll create a track object that monitors whether an interface’s line-protocol is up or down.
On R1, create track object 100 to monitor the line-protocol state of Ethernet0/2:
R1(config)#track 100 interface Ethernet0/2 line-protocol
R1(config-track)#exit
R1(config)#
This track object immediately detects when Ethernet0/2’s line-protocol goes down and reports that change to HSRP, which can then trigger a failover.
The line-protocol keyword monitors the line protocol state of the interface. That’s the second half of what you see in show interfaces:
Ethernet0/2 is up, line protocol is up
The first part is the hardware/administrative status, the second part is the line protocol (Layer 2) status. Our track object follows that second part. Shutting the interface down or pulling the cable takes the line protocol down, so the object goes down too.
Alternatively, you can use ip routing. This is a bit stricter. The object is only up when all three of these conditions are true:
- IP routing is enabled and active on the interface.
- The line protocol state of the interface is up.
- The interface has a known IP address.
If any of these three is false, the object goes down. In other words, ip routing includes everything line-protocol checks, and then some.
Why would you want that? The classic example is a serial interface running PPP. LCP can negotiate successfully so the line protocol is up, while IPCP negotiation fails so the interface never gets a usable IP address. With line-protocol the track object stays up and HSRP happily keeps forwarding into a black hole. With ip routing the object goes down and you get your failover. The same idea applies to any interface where the IP address is negotiated or learned instead of statically configured, for example DHCP or IPCP.
For a plain Ethernet uplink with a static IP address like the one in this lab, line-protocol is what you want.
| Keyword | Object is up when | Typical use |
|---|---|---|
line-protocol |
The interface line protocol is up (Layer 2). | Interfaces with a static IP address. Most failover scenarios. |
ip routing |
IP routing is enabled and active on the interface, the line protocol is up, and the interface has a known IP address. | Interfaces where the IP address is negotiated or learned, for example PPP/IPCP or DHCP. |
HSRP Group with Priority Decrement
Now configure HSRP Group 1 on Ethernet0/1 and associate it with track object 100. When track object 100 goes down, R1’s priority will be decremented by 10 points, allowing R2 to become the active router. Here’s how to do this:
R1(config)#interface Ethernet0/1
R1(config-if)#standby 1 priority 110
R1(config-if)#standby 1 preempt
R1(config-if)#standby 1 track 100 decrement 10
R1(config-if)#standby 1 ip 192.168.12.254
R1(config-if)#exit
R1(config)#
Let me explain what we have here:
standby 1 priority 110sets R1’s priority to 110 for Group 1, making it the active router.standby 1 preemptenables HSRP Preemption so that R1 will actively claim the active role if its priority becomes higher than the current active router.standby 1 track 100 decrement 10associates track object 100 with this HSRP group and specifies that the priority should be reduced by 10 when the track object goes down.standby 1 ip 192.168.12.254sets the virtual IP address that end hosts will use as their gateway.
The decrement value must be chosen so that the active router’s priority drops below the standby router’s priority when the tracked object fails. In this lab, R1’s priority is 110, and R2’s is 105, so a decrement of 10 is sufficient:
110 – 10 = 100, which is less than 105.
Preemption is required for the standby router to claim active status when the active router’s priority decrements. Without standby 1 preempt enabled, the standby router won’t take over even if the active router’s priority drops below the standby router’s priority. As a best practice, enable it on both routers.
Track Object and HSRP Group on R2
It is a good idea to configure object tracking on both routers. It’s not a hard requirement, but it’s wise to make R2 monitor the same condition. Without it, R2 keeps its priority of 105 no matter what happens to its own uplink. If R2’s Ethernet0/2 fails, R2 stays at 105 while R1 sits at 110, so R1 remains active. That sounds fine until R1’s uplink fails as well: R1 drops to 100, R2 is still at 105, and R2 takes over as the active router even though it has no working uplink either. Configuring the same track object on both routers keeps the gap between them constant, so the router with the higher configured priority wins whenever both are in the same shape.
We’ll create the track object:
R2(config)#track 100 interface Ethernet0/2 line-protocol
R2(config-track)#exit
Now configure HSRP Group 1 on R2 with a lower priority so it becomes the standby router. R2’s priority is 105, which is lower than R1’s 110:
R2(config)#interface Ethernet0/1
R2(config-if)#standby 1 priority 105
R2(config-if)#standby 1 preempt
R2(config-if)#standby 1 track 100 decrement 10
R2(config-if)#standby 1 ip 192.168.12.254
R2(config-if)#exit
R2(config)#
R2’s priority of 105 is lower than R1’s 110, so R2 will be the standby router. However, if track object 100 fails on R1, R1’s priority will be decremented to 100, which is lower than R2’s 105. At that point, R2 will become active because it still has the higher priority.
This completes the configuration.
Verification
Let’s verify our work.
HSRP Group Status Before Failure
Once HSRP has converged, let’s verify the group status on both routers to confirm that R1 is the active router.
On R1, check the brief HSRP status:
R1#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Et0/1 1 110 P Active local 192.168.12.2 192.168.12.254
R1 is the active router for Group 1 with priority 110. R2 is the standby router at 192.168.12.2. On R2, verify the standby status:
R2#show standby brief
P indicates configured to preempt.
|
Interface Grp Pri P State Active Standby Virtual IP
Et0/1 1 105 P Standby 192.168.12.1 local 192.168.12.254
R2 is in standby state, confirming that R1 is active.
HSRP Information with Track Objects
Now let me show you the detailed information about HSRP Group 1 on R1, including the status of the track object:
R1#show standby
Ethernet0/1 - Group 1
State is Active
2 state changes, last state change 00:00:47
Virtual IP address is 192.168.12.254
Active virtual MAC address is 0000.0c07.ac01 (MAC In Use)
Local virtual MAC address is 0000.0c07.ac01 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 0.512 secs
Preemption enabled
Active router is local
Standby router is 192.168.12.2, priority 105 (expires in 9.216 sec)
Priority 110 (configured 110)
Track object 100 state Up decrement 10
Group name is "hsrp-Et0/1-1" (default)
FLAGS: 1/1
Notice the key line: Track object 100 state Up decrement 10. This tells you that the track object is currently in the up state, so no priority adjustments are being applied.
On R2, the output confirms the standby state: