Community discussions

MikroTik App
 
mcrose
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 60
Joined: Wed May 06, 2009 8:00 pm

Enable/disable static route as links go up and down

Thu Dec 15, 2011 4:59 pm

Assuming the following routing table and config, with two OSPF instances providing a default route over each of two interfaces:
#      DST-ADDRESS        PREF-SRC        GATEWAY            DISTANCE
0 A S  0.0.0.0/0                          192.168.10.2              1
2 A S  0.0.0.0/0                          192.168.10.10             1
4 ADo  0.0.0.0/0                          192.168.10.2            110
5  Do  0.0.0.0/0                          192.168.10.10           110

/ip firewall mangle
add action=mark-routing chain=prerouting disabled=no in-interface=ether4 \
    new-routing-mark=left passthrough=yes
add action=mark-routing chain=prerouting disabled=no in-interface=ether5 \
    new-routing-mark=right passthrough=yes

/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    192.168.10.2 routing-mark=left scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=\
    192.168.10.10 routing-mark=right scope=30 target-scope=10
As expected, the router chooses one of the two OSPF instances' default routes to be the active one, with the other in the routing table yet not active.

However, check-gateway=ping is not the correct criteria for disabling the static routes that preferentially route traffic along one of the two paths depending on the source IP. Assuming there's more than one node between the device whose IP is the gateway and the Internet router, a link past the immediate gateway could go down and kill the OSPF derived route but the static route would still merrilly send traffic to the gateway who now has no route to the Internet.

i.e, the topology would be:
  A_ospf           A_ospf
instance 1      instance 2
          \        /
           B     D
           |     |
           C     E
             \  /
               F -- Internet
* Note that A does not close the B-D loop and route between them due to running a separate OSPF instance on each facing interface that do not redistribute routes between them.

With router A with the static routes passing traffic along one of the two directions, if router C would go down check-gateway would still ping both static default routes as up against B and D, but B would no longer have a route to 0.0.0.0/0.

This really needs to be done by seeing if the router sees a dynamic ospf-provided default route that matches the immediate gateway set in the static route. When a link goes down OSPF will note it and remove the dynamic default route from the routing table of router A, at which point A should note this and disable the static route until which time as OSPF recreates the dynamic route.

I can't find anything in the router that will do this. How would I go about doing this sort of thing?

Who is online

Users browsing this forum: aferreira and 169 guests