In networking when adding a static route to a router, the static route will make its way into the RIB and FIB if the router can reach the next hop and knows which interface to go out towards its destination. In theory, if the next hop becomes unreachable then the static route is removed from the active routing table until that next hop comes back. This does not work however if there’s an intermediary device in that layer 2 broadcast domain.
On the devices above we have the following interfaces, IPs, and static route.
Interface IP: 22.214.171.124/29
ip route 126.96.36.199/32 188.8.131.52
interface IP: 184.108.40.206/29
Interface Loopback0: 220.127.116.11/32
Nothing, all layer 2
Currently R1’s route table shows the static route is valid and the router can ping R2’s transit interface.
When R2’s interface is set admin down unfortunately R1’s static route does not leave the routing table, even though the next hop is no longer reachable.
This is because the layer 2 device in between is keeping R1’s interface alive. One way of fixing this is with IP SLA. We’ll configure an IP SLA agreement statement that continues to ping R2’s interface, and when the ICMP echo fails, we’ll schedule R1 to remove the static route.
The first part of the simple IP SLA configuration is adding the IP SLA statement with ‘ip sla 1’. It’s using icmp-echo to R2’s transit IP address. And the start time is now with a lifetime of forever. Once this.
Once that’s completed a tracking object needs to be created. The track statement has the number 1 and its associated with IP SLA1. After this is configured a console message will show onscreen saying the the IP SLA has gone from down to up.
The tracking statement needs to now be associated with the static route in R2’s routing table. That can be done with the below command(s):
no ip route 18.104.22.168 255.255.255.255 22.214.171.124 track 1
ip route 126.96.36.199 255.255.255.255 188.8.131.52 track 1
First the old route statement needs to be removed, then the new route with tracking gets enabled.
Below is an image of the route table before R2’s interface is shutdown:
And after R2’s interface is shutdown:
A message above shows the IP SLA 1 state went down. In the route table there is now an entry for the R2 loopback but over another route with a higher administrative distance.