O'Reilly logo

Cisco IOS Cookbook, 2nd Edition by Ian Brown, Kevin Dooley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Static Routes That Track Interfaces or Other Routes

Problem

You want to install a static route only when an interface fails or a prefix drops out of the routing table.

Solution

One of the interesting new features in IOS Versions 12.3T and 12.4 is the ability to track things like interface status or routing table objects. This first example shows how to create a static route that tracks an interface:

Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#track 10 interface Serial0/0 line-protocol
Router(config-track)#delay down 5 up 30
Router(config-track)#exit
Router(config)#ip route 192.168.10.0 255.255.255.0 10.3.12.26 track 10
Router(config)#end 
Router#

This second example shows how to create a static route that tracks a prefix in the IP routing table:

Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#track 11 ip route 10.2.95.0 255.255.255.0 reachability
Router(config-track)#delay down 5 up 5
Router(config-track)#exit
Router(config)#ip route 0.0.0.0 0.0.0.0 10.3.12.26 track 11
Router(config)#end 
Router#

And the final example installs the static route when a combination of the previous conditions is met:

Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#track 12 list boolean and
Router(config-track)#object 10 not
Router(config-track)#object 11 
Router(config-track)#exit
Router(config)#ip route 192.168.13.0 255.255.255.0 10.3.12.26 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required