Just for reference really: I needed to have a static route whose presence depended on the IP reachability of a host. If the host wasn’t there, the static route should disappear, and default routing take over.
The configuration of this is made a bit confusing by the fact that Cisco changed the CLI commands from ‘rtr’ to ‘ip sla’ at some point.
Basically there are three parts to this puzzle:
1. The IP SLA (or RTR) probe which sends ICMP echoes to the host
2. The ‘tracking object’ which monitors the SLA’s return code
3. The static route referencing the tracking object.
Configuration is like this:
ip sla monitor 20
type echo protocol ipIcmpEcho 192.168.2.2
timeout 1000
frequency 2
ip sla monitor schedule 20 life forever start-time now
!
track 101 rtr 20
!
ip route 10.1.1.0 255.255.255.0 192.168.2.2 track 101
The first section sets up the SLA monitor, telling it what to ping, how frequently, and what the timeout is.
The ‘ip sla monitor schedule’ command tells the SLA monitor to start and to run indefinitely.
The ‘track’ command simply references the IP SLA.
Finally, the static route references the track object. If the SLA fails because the pings aren’t succeeding, the track object goes down, and the static rout is removed from the table.
Verification of this can be done as follows. Note that I have two SLAs and two track objects – deliberately so that you can see one that is down and one that is up:
R1#sh ip sla mon operational-state Entry number: 10 Modification time: *04:09:04.554 UTC Fri Mar 1 2002 Number of Octets Used by this Entry: 2272 Number of operations attempted: 534 Number of operations skipped: 0 Current seconds left in Life: Forever Operational state of entry: Active Last time this entry was reset: Never Connection loss occurred: FALSE Timeout occurred: TRUE Over thresholds occurred: FALSE Latest RTT (milliseconds): NoConnection/Busy/Timeout Latest operation start time: *04:26:50.554 UTC Fri Mar 1 2002 Latest operation return code: Timeout RTT Values: RTTAvg: 0 RTTMin: 0 RTTMax: 0 NumOfRTT: 0 RTTSum: 0 RTTSum2: 0 Entry number: 20 Modification time: *04:12:53.714 UTC Fri Mar 1 2002 Number of Octets Used by this Entry: 2272 Number of operations attempted: 420 Number of operations skipped: 0 Current seconds left in Life: Forever Operational state of entry: Active Last time this entry was reset: Never Connection loss occurred: FALSE Timeout occurred: FALSE Over thresholds occurred: FALSE Latest RTT (milliseconds): 16 Latest operation start time: *04:26:53.714 UTC Fri Mar 1 2002 Latest operation return code: OK RTT Values: RTTAvg: 16 RTTMin: 16 RTTMax: 16 NumOfRTT: 1 RTTSum: 16 RTTSum2: 256
Here are the track objects:
R1#sh track
Track 100
Response Time Reporter 10 state
State is Down
1 change, last change 00:16:46
Latest operation return code: Timeout
Tracked by:
STATIC-IP-ROUTING 0
Track 101
Response Time Reporter 20 state
State is Up
1 change, last change 00:13:29
Latest operation return code: OK
Latest RTT (millisecs) 8
Tracked by:
STATIC-IP-ROUTING 0