If you want to communicate to anything other than your connected network, you must have routes for the destinations. This can be a scale issue when one wants to communicate with random IP addresses like when surfing around on the Internet. Basically you have two options to do this. Either you know all the destinations, or you have a default route(r) that blindly takes care of reachability for you. I’d like to walk through the various protocols to see how you can inject a default route.
OSPF has many knobs to turn for default routing. Let’s explore them:
You might be familiar with the default-information originate command under the OSPF process. Yes this is how you can inject a Type-5 LSA into OSPF – either unconditionally using the keyword always or based on having a default route in the routing table before it will inject one into OSPF. This is basic default routing with OSPF. What most people do
Conditional Route Injection
OSPF supports conditional route injection using a route-map. When the route-maps condition is satisfied, OSPF will inject a default route.
We can illustrate this using a single router and look in the OSPF LSDB. Let’s say we want do inject a default route only if we have a route to some destination. Below is a configuration example for R2 who has a static route to R1s Lo0 IP addresss of 18.104.22.168/32. We will configure R2 to inject a default route only if the route is installed in its routing table.
! R2 inject default route: R2(config)#ip prefix-list r1lo0 permit 22.214.171.124/32 R2(config)#route-map ospfdef permit 10 R2(config-route-map)#match ip address prefix r1lo0 R2(config-route-map)#router ospf 1 R2(config-router)#default-information originate route-map ospfdef
Let’s see if R2 did inject a default route:
! R2 verification: R2#sh ip ospf database external 0.0.0.0 OSPF Router with ID (10.0.12.2) (Process ID 1) Type-5 AS External Link States LS age: 693 Options: (No TOS-capability, DC, Upward) LS Type: AS External Link Link State ID: 0.0.0.0 (External Network Number ) Advertising Router: 10.0.12.2 LS Seq Number: 80000001 Checksum: 0x801A Length: 36 Network Mask: /0 Metric Type: 2 (Larger than any link state path) MTID: 0 Metric: 1 Forward Address: 0.0.0.0 External Route Tag: 1 R2#
Yes, we have a default route. Let’s try to remove the route from the routing table by configuring an AD of 255 and look at what happens:
! R2 delete route: R2#debug ip ospf spf R2#conf t R2(config)#ip route 126.96.36.199 255.255.255.255 10.0.12.1 255 ! Wait a while and we see this debug message: *Dec 14 20:02:42.413: OSPF-1 EXTER: Process partial spfQ: type 5, LSID 0.0.0.0, mask 0.0.0.0, adv_rtr 10.0.12.2, age 3600, seq 0x80000002, area dummy area
And if we look at the LSDB of R2 again:
! R2 LSDB without a route to R1: R2#sh ip ospf database external 0.0.0.0 OSPF Router with ID (10.0.12.2) (Process ID 1) R2# R2#
Nothing because our condition is not met.