Community discussions

MikroTik App
just joined
Topic Author
Posts: 18
Joined: Mon Jan 07, 2013 11:11 am

OSPF route vs static route

Sat Mar 11, 2017 8:41 pm

I cannot override a static route with OSPF route even if I set the distance of the static route above 110 (default OSPF distance).

With BGP I can! Just by setting distance of the static route above 200 (default BGP distance).

Is it supposed to be like that? Shouldn't OSFP insert routes to the routing table, if distance of "conflicting" static routes are bigger than distance of corresponding OSPF routes?
User avatar
Posts: 3046
Joined: Wed Dec 04, 2013 11:09 am
Location: Spain

Re: OSPF route vs static route

Sun Mar 12, 2017 12:41 am

Post your routing, and be more specific, you'll get much more chances of getting help.
Simplicity is the Ultimate Sophistication - Da Vinci
Getting the most out of this forum
User avatar
Forum Guru
Forum Guru
Posts: 4052
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF route vs static route

Fri Mar 17, 2017 8:11 pm

Yes, that's how it's supposed to work. However, the current ROS implementation of OSPF has a bug where if a router is injecting a prefix into OSPF based on a "floating static" route (this is true for default-originate routes and for any redistributed routes, whatever the source), the OSPF process will ignore this prefix if it learns it from some other OSPF source.

So to make it easier, let's make an example:
route to is normally learned via OSPF (Distance=110)
floating static route to is configured with distance > 110. (e.g. 254)
Normal condition: router uses the ospf-learned route.
OSPF withdraws the prefix
Floating static route becomes available
This router now injects into OSPF based on the now-active floating static route
Original source of the prefix is restored, and ospf sends this LSA to the "floating static backup" router.
The backup router installs the original route, but leaves it disabled, so the floating static route will never be withdrawn.

The reason is because normally, an OSPF router should never use a learned route to reach a prefix which the router is also itself injecting into OSPF, as this can lead to routing loops.
Mikrotik's solution to this rule is that it ignores the prefix entirely, when what it should do is stop injecting the route and start using the OSPF route. I reported this behavior to Mikrotik over a year ago, and was told that this behavior will be addressed in RouterOS 7. In the mean time, the only way to "normalize" your routing is to go into the backup router and manually disable the floating static route so OSPF will revert to the correct path, and then re-enable it so that it will work again the next time the primary route fails.
When given a spoon,
you should not cling to your fork.
The soup will get cold.
just joined
Posts: 1
Joined: Sat Apr 11, 2020 11:03 am

Re: OSPF route vs static route

Sat Apr 11, 2020 11:10 am

It's 2020 and the problem still exists.

A work around for whoever finds this article:

Inject two smaller routes on the router with the preferred link, smaller routes should always win over bigger routes.

Use the static routes 10.2.3..0/25 +
instead of on the preferred link.
just joined
Posts: 23
Joined: Thu Apr 03, 2008 2:18 am

Re: OSPF route vs static route

Thu Sep 16, 2021 8:31 am

And now it's 2021, approaching 2022 ...
Inject two smaller routes on the router with the preferred link, smaller routes should always win over bigger routes.
This works well (and what we've done in the past too) until you have a really insane stupid number of /32s ... what would be great is if we can base the ospf-metric for static routes from the distance, and unless the locally injected is selected, inject the selected OSPF route back into main routing table (if static goes away (or becomes inactive?) we stop injecting, so not seeing how this can cause routing loops).

But alas ... RouterOS7 solves world peace too. And based on past experience with upgrading major versions of RouterOS I'm not looking forward to that upgrade.

Who is online

Users browsing this forum: No registered users and 7 guests