Sometimes a routing protocol such as OSPF or BGP is not available with your next hop and you need to be able reroute traffic based on conditions. There are different ways to do this, but my favorite is via track tables and IP SLA.
What is nice about this method is that it allows routing by reachability or other methods to determine if the route is useable. At home I have two internet providers but cannot count internet access just because their equipment has power. I use this to change my default route and insert a static route or delete it based on that same reachability.
sample:
track 2 ip sla 2
delay down 5 up 3
!
track 4 ip sla 4
delay down 5 up 3
ip sla 2
icmp-echo 10.20.20.1 source-interface BVI2
threshold 1000
frequency 5
ip sla schedule 2 life forever start-time now
ip sla 4
! note I am not pinging the default gateway here, but a destination behind it to make sure I can reach past this default gateway
icmp-echo 10.30.40.1 source-interface FastEthernet4
threshold 1000
verify-data
frequency 5
ip sla schedule 4 life forever start-time now
interface BVI2
! need to get the route into the track table, I could ignore but not really a static IP
ip dhcp client default-router distance 10
ip dhcp client route track 2
! this actually will prefer the 10 default route from BVI2 dhcp but just in case
ip route 0.0.0.0 0.0.0.0 10.20.20.1 250 track 2
ip route 10.10.10.10 255.255.255.255 10.20.20.1 track 2
ip route 0.0.0.0 0.0.0.0 10.30.30.1 251 track 4
In order to use this with NAT it requires route-maps and policy based routing. [link will be here when I finish simplifying/abstracting it]
I didn't know.