Conditional OSPF Default Route: Tested Configuration
One of my readers asked for a working configuration of the conditional OSPF default route advertisement feature. In my scenario, the OSPF default route would be announced whenever an Internet prefix (172.18.0.0/16) would be present in the IP routing table.
router ospf 1
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
default-information originate always route-map FromInternet
!
router bgp 11
bgp log-neighbor-changes
neighbor 172.16.1.2 remote-as 21
!
ip access-list standard FromInternet
permit 172.18.0.0
!
route-map FromInternet permit 10
match ip address FromInternet
Caveats:
- The route map configured in the default-information originate command tests the IP prefixes in the IP routing table. You can thus match only on those attributes that are present in the IP routing table (IP prefix, metric, next-hop), not on additional BGP attributes (like AS-path), which would be really cool
- Contrary to what Sebastian wrote in his comment, you don’t have to redistribute the BGP route into OSPF to make it work in IOS release 12.4(11)T or 12.2SRC, but it looks the IP prefix you test cannot be a subnet.
That's strange, it didn't work for me in 12.4(11)T, and this is the response I got from TAC:
------------------------
the problem with originate default information is that it's a special redistribution. In this configuration you 'redistribute' into OSPF routes x.x.x.x/16 and y.y.y.y/20 with the only exception that during redistribution they become default route.
This said, usual restrictions on redistribution apply and iBGP routes are not redistributed into IGP.
------------------------
Perhaps I have a special configuration which triggered the problem, I don't know.
FYI: matching on next-hop didn't work.. using tags is cleaner anyway.
EIGRP's default-information originate would add a Classful static entry into to the config but OSPF does not.
Sharath
default-information originate always route-map TEST_1
route-map TEST_1 permit 10
match ip next-hop 12
route-map TEST_1 permit 20
match ip next-hop 13
access-list 12 permit 192.10.1.254
access-list 13 permit 204.12.1.254
show ip route
B 118.0.0.0/8 [20/0] via 204.12.1.254, 00:42:37
B 222.22.2.0/24 [20/0] via 192.10.1.254, 00:27:02
http://blog.ipspace.net/2007/08/install-static-route-when-ip-address-is.html
I tested it by means of IP SLA and Boolean Not and it worked, as you pointed out, a bit obscure though. I am going to test what you suggested.