Showing results for 
Search instead for 
Did you mean: 

Conditional default route advertisement in OSPF




Cisco device uses “default-information originate” statement to generate a default route in OSPF domain. There are two ways to originate default route by using this command:

1) When you configure “default-information originate”  under OSPF process  without any argument after this statement, OSPF process will  first check,if any default route is already present in routing table. If a default route is already present in routing table via static or any dynamic protocol, OSPF originate default route. If default route does not exist in routing table, OSPF will not originate default route.

2)This behavior can be modified by adding "always" argument to the "default-infomation orginate" statement,which essentially skips the checking for a default route already being installed in the table.


This document discuss about conditional route origination in OSPF domain. Conditional default route in OSPF originate by using route-map in default-information command under router OSPF process. The route map configured in the default-information originates command check the existing IP prefixes in the IP routing table.

Configuration steps:

1) prefix-list or access-list: To originate default route only when necessary prefixes are present in routing table.First you need to match these prefixes by configuring prefix-list or access-list.


Prefix-list configuration:

Router (config)#ip prefix-list Default_route sequence 10 permit


Access-list configuration:

Router(config)#ip access-list standard Default_route

Router(config-std-nacl)# permit


2) Attach prefix-list or access-list in route map:


Router(config)#route-map Ospf_default permit 10

Router(config-route-map)#match ip address prefix-list Default_route



3) Configure “default-information originate always route-map” statement:


Router(config)#router ospf 100

Router(config-router)#default-information originate always route-map Ospf_default 



In the below topology R1 is connected to two ISP using serial interface. The router R1 and R2 runs OSPF in Area 0, where R1 is advertising default route to R2 only when both serial links are up. Once both link goes down R1 should withdraw default route from OSPF domain.


Topology Diagram:





Configuring R1:

R1(config)#ip prefix-list default_route sequence 10 permit

R1(config)#ip prefix-list default_route sequence 20 permit

R1(config)#route-map ospf_default permit 10

R1(config-route-map)#match ip add prefix-list default_route


R1(config)#router ospf 100

R1(config-router)#default-information originate always route-map ospf_default



R1 advertise a default route to OSPF domain, as both ISP links are up.


Verifying default route on R2

R2#sh ip ospf database | in     371         0x80000001 0x0018CA 100


R2#sh ip route ospf

O*E2 [110/1] via, 00:06:22, FastEthernet0/0


We need at least one prefix match in list present in R1’s routing table to advertise default route in OSPF domain.

Disabling one link towards ISP1:

R1(config)#int s0/0


*Mar  1 00:17:09.971: %LINK-5-CHANGED: Interface Serial0/0, changed state to administratively down

*Mar  1 00:17:10.971: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down


Verification on R2:

R2#sh ip route ospf

O*E2 [110/1] via, 00:10:30, FastEthernet0/0


Disabling remaining link towards ISP2:

Verification on R2:

R1(config-if)#int s0/1



*Mar  1 00:18:39.131: %SYS-5-CONFIG_I: Configured from console by console

*Mar  1 00:18:39.731: %LINK-5-CHANGED: Interface Serial0/1, changed state to administratively down

Turned on debug in R2 to get closer view of default route deletion

R2#debug ip routing

IP routing debugging is on

*Mar  1 00:19:25.799: RT: del via, ospf metric [110/1]

*Mar  1 00:19:25.803: RT: delete network route to

*Mar  1 00:19:25.803: RT: NET-RED

*Mar  1 00:19:25.803: RT: NET-RED


R2#sh ip route ospf


From the above output it is clear that when the both links connected to ISP goes down, router R1 stop generation of default route to OSPF domain.

Related Information

How to inject a default route into OSPF
How Does OSPF Generate Default Routes?

Verifying default route on R2


once route-map argument used, having a static route already existing in routing table is no longer required to announce an OSPF default route?

In order to withdraw the default route when the upstream link goes down, is it better to use static default with IP SLA instead of route-map?


I am searching this document only for my Routing exam

Thanks Ashish for sharing the same


Not sure how to post a new question.. so I'll try here.

I have a router running ospf and BGP. I'm trying to establish the following behavior regarding the default route:
If we learn default from OSPF neighbor, install in routing table
If we learn default from BGP, install into routing table and inject into OSPF.
inject default from static into routing table.

I'm using "network backdoor" to prefer the ospf route over bgp.
Static route has AD of 210, so BGP preferred over static.

I'm unable to inject default into the routing table. Using a route-map to try to conditionally inject the route:

router ospf 100
default-information originate metric 3000 route-map ospf_def

route-map ospf_def permit 10
description learning quad0 from VSAT
match source-protocol static
set metric 5000
set tag 1010007
route-map ospf_def permit 30
description default route from BGP
match source-protocol bgp 65036
set metric 100
route-map ospf_def deny 100
Not getting the default route into OSPF.