OSFP originate default route if present locally


I’ve got a router with eBGP session. I learned default route through this BGP session.
I want to redistribute default route into my OSPF network but only if the default route is installed locally and active.

I mean for example if BGP session get down for any reason OSFP must stop to originate default.
As a plus, I would like set type (1 or 2) for such route

I’ve tried to achieve it with route-map but I’ve missed something and I’m unable to get it working.
I don’t know how to test if route exists or not. Does I need to IP SLA ?

Note that I use a Cisco Nexus 9000 (N9K-C92160YC-X ) with NX-OS 9.3(7)

Thank you for the help.

Hello Sebastien

This is the expected behaviour on Cisco devices. You cannot redistribute a default route into OSPF. The only way you can have OSPF learn about a default route from another source is to inject it into OSPF using the default-information originate command. You can use route maps or prefix lists, but the device will simply ignore the redistribution.

Now, if I understand correctly what you want to achieve, then you should be able to do this using the default-information originate command. Remember that this command will inject a default route into OSPF only if it is in the routing table. Since the default route is being learned via eBGP, it will be in the routing table only when BGP is running correctly.

This means that if the BGP session goes down, the default route learned via eBGP will be removed from the routing table, thus it will not be injected into OSPF.

Now the command default-information originate always will make the OSPF router advertise itself as the default route even if there is no default route in its routing table. The always keyword should not be used in your case, to ensure that OSPF will learn of a default route ONLY if a default route exists in the local routing table. More about this particular scenario can be found int he OSPF Default Route section of this lesson:

By default, such an injected route has a default metric of 10, and is a type 2 external route. You can modify this using additional keywords in the command. More about this in the following Cisco command reference:

These references are for IOS devices, but it is largely the same for Nexus devices as well.

I hope this has been helpful!


Thank you for reply. It’s working now.
The problem was a Mikrotik router that inject default route as type 1. We have used route map on Cisco to switch type 2 to type 1 and now everything is working perfectly.

1 Like