OSPF Default Route AlternativesMarch 10, 2009
Assume R3 is a breakout for your network, and lets assume for a second you want to advertise a default route into the OSPF domain, but on the condition that you have reachability to the Gateway (GW) 18.104.22.168.
The usual and a really easy way to do this is by originating a default-route based on a route-map with a condition that a specific route is in the routing table.
ip address 22.214.171.124 255.255.255.0
ip prefix-list GW seq 5 permit 126.96.36.199/24
route-map DEF-GW permit 10
match ip address prefix-list GW
router ospf 1
default-information originate route-map DEF-GW
This will work, but there is a design flaw to this particular setup. This setup is based on the prefix 188.8.131.52/24 being in the routing table, but since Gi0/0 is a connected interface, that prefix will always be in the routing table, whether or not the GW router is up or down. Remember this is a not a serial link, where the link state could determine point-to-point reachability. The only time that prefix will not be in the routing table and as a result, not originate the 0.0.0.0/0 default-route, is when the physical local connection to the switch dies. Inevitably this will create a black-hole, which is no good.
So now what. You need to have some form of tracking the IP address on the remote-end, not just the interface state.
We could do this by using a IP Sla Monitor, track the remote-end IP, conditionally create a default route in the routing table, and then when we have reachability, originate the default route into OSPF .
First we would create the Ip Sla Monitor:
ip sla monitor 1
type echo protocol ipIcmpEcho 184.108.40.206 source-interface GigabitEthernet0/0
ip sla monitor schedule 1 life forever start-time now
Next, setup the Track that your conditional static route would reference before creating the default route:
track 1 rtr 1
ip route 0.0.0.0 0.0.0.0 Null0 track 1
Then the easy part, originate and advertise a default route into the OSPF domain if 0.0.0.0/0 is available in the routing table:
router ospf 1
Now if the GW router goes, or the local Gi0/0 interface dies, the default route would be removed from the routing table, and as a result R3 would stop originating a default route, until connectivity is restored.