default route thru received by OSPF network

I have OSPF router.
Let’s say I’ve receive 192.168.100.0/24 thru OSPF (this is not link network).
And … There is a reason why I cannot receive default route on my OSPF router.

Is there a way to setup static default route in case if I have 192.168.100.0/24 in routing table?
I setup “ip route add gateway=192.168.100.20” but looks like it unreachable.

My idea is the next: I want to setup two gateway
a) first (primary) should work if I receive specific network thru OSPF
b) second should work in case if specific route has not received.

Is that possible?

You can run a script that enables static default route if specific ospf route is present in routing table. However it is not necessary.
Proper configuration would be to set OSPF on both gateways to distribute default route. OSPF will automatically switch to other gateway if primary fails.

hmm…
Script is one way … Looks like it’s work for me.
Could you share some simple example of it ? :confused:

The real life task is a bit difficult to explain, so the proper configuration of OSPF does not help me.
I’m really should play only with existing routes. If I have it, then def gateway is IP1, if do not have then def gateway is IP2.

add default route with comment
/ip route add gateway=x.x.x.x comment=“default1”

Then add script:
{
:if ( [/ip route find dst-address=192.168.100.0/24] !=“” ) do={
/ip route enable [find comment=“default1”];
} else={
/ip route disable [find comment=“default1”];
}
}

Adjust the script for your needs

Thanks a lot !!!

Hmm … The Script work fine.
But… How I can start it “automaticaly” ?

/system scheduler