Using the Track Statement

Assume you have the following hypothetical scenario, R2 and R7 on one site, connected to a WAN infrastructure via multiple links (omitted here), where there are two gateways R5 & R6:

track

Client requests the following:

  • R2 should be the active HRSP router if R2 has connectivity to BOTH R5 and R6 loopbacks.
  • R7 should be the active HSRP router if R2 has connectivity to only ONE of the 2 gateways.
  • R2 should be the active HSRP router if R2 has NO connectivity to either R5 or R6.

The use of the track statements and a boolean expression, in conjunction with HSRP would suffice.

The first requirement is, if both 5.5.5.5/32 and 6.6.6.6/32 are in the routing table of  R2, then R2 should be Active. If one of these routes disappears, R7 should become Active, and lastly if both routes disappear, R2 should become Active again.

The first two are easy, with two track statements, Track1 for 5.5.5.5/32 and Track2 for 6.6.6.6/32 and correct decrement amounts. But the last poses more of a challenge.

By using the boolean ‘AND’ statement for both Track1 and Track2, you’ll have the third track to meet the requirements.

The config for these track statements are as follow:
R2#
track 1 ip route 5.5.5.5 255.255.255.255 reachability
track 2 ip route 6.6.6.6 255.255.255.255 reachability
track 3 list boolean and
object 1 not
object 2 not

Track1 would be ‘TRUE’ if 5.5.5.5/32 is present in the routing table, ‘FALSE’ if non existent in the routing table. Same for Track2.

Track3 says if (Object1 = Track1 is not true, ie false) AND (Object2 = Track2 is not true), thus if both routes are not present in the routing table, then Track3 will be ‘TRUE’. If one or both of these router are present in the routing-table, Track3 is ‘FALSE’.

With HSRP’s decrements statements, if the Track status is TRUE/UP, no decrement action is necessary, but if the Track status is FALSE/DOWN, then the specified amount will be deducted from the configured priority amount on that interface.

The configuration on the Ethernet interfaces to complete this :

R7#
interface FastEthernet0/0
ip address 142.42.27.7 255.255.255.0
standby version 2
standby 27 ip 142.42.27.27
standby 27 priority 95
standby 27 preempt

R2#
interface FastEthernet1/0
ip address 142.42.27.2 255.255.255.0
standby version 2
standby 27 ip 142.42.27.27
standby 27 priority 150
standby 27 preempt
standby 27 track 1 decrement 10
standby 27 track 2 decrement 10
standby 27 track 3 decrement 50

R7 uses a priority of 95 and R2 uses a priority of 150. These values are based on the decrement values used by the track statements. Let me explain:

Firstly what does Track3 do again?

Track3 is UP if both Track1 and Track2 are DOWN! If Track3 is UP, the priority is not decremented by 50.

But Track3 will be DOWN if either, or both Track1 and/or Track2 are UP. If Track3 is DOWN the priority is decremented by 50, to have a HSRP priority of 100, under normal circumstances. With a priority of 100 R2 will be the Active HSRP router, since R7 has a priority of 95. Biggest priority always wins.

But if Track1 goes to a DOWN state (ie 5.5.5.5/32 removed from the routing table), the priority of 100 is decremented by 10 to 90. This will make R7 the Active HSRP router since R7 now has the highest priority with 95.

If in addition, 6.6.6.6/32 disappears from the routing table, Track2 will also go DOWN, along with Track1, then only will Track3 kick in. (If Track1 & Track2 = DOWN, then Track3 is UP). The priority (100) on the interface of R2 will be increased with 50, to 150, but be decremented by 2x 10 for Track1 and Track2. This will give Router2 a interface priority of 130, thus higher than Router7’s 95, and become Active again.

Lets see this on the CLI for better understanding:

.

Default Situation

Since both 5.5.5.5/32 and 6.6.6.6/32 are present in the routing table, Track1 and Track2 are up, and as a result Track3 is down:

track1

The interface on R2 shows the status of the tracks, and the priority, currently a 100 due to Track3 being down. (Configured priority 150 – Track3 (50)  = 100). Notice R2 is in Active State.

track2

.

One Route Down :

Let see what happens when 5.5.5.5/32 is not reachable from R2 anymore.
That will cause Track1 to go DOWN, therefor the priority is decremented by an additional 10 to 90.  Notice R2 is not Active anymore, due to R2’s 90 priority being less than R7’s 95 priority.

track3

.

Both Routes Down

When both 5.5.5.5/32 and 6.6.6.6/32 are unreachable from R2, Track1 and Track2 will be DOWN. Thus the boolean ‘and’ will change the status of Track3 to UP.  Since Track3 is now UP, only the amounts of the DOWN objects (Track1 and Track2) are used to decrement the priority from 150 -10 -10 to 130. Notice that R2 is Active again.

track4

.

Advertisements

One thought on “Using the Track Statement

Please leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s