Community discussions

MikroTik App
 
shivansps
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Fri Sep 22, 2017 1:18 am

No internet if there is not a route whiout a routing mark

Wed Oct 09, 2019 6:27 pm

Hi, in trying to setup a better WAN failover using this guide:
https://wiki.mikrotik.com/wiki/Advanced ... _Scripting

Just the basic setup, so far so good, i have that set up, using 1.1.1.1 and 8.8.4.4 as hosts i also have a DHCP lease script running to update the gateways on the first part as i have two cablemodem conections with dynamic ips.

Using mangle i was able to set a specific IP to use "ISP1" and "ISP2" routing mark, this works so, so far this is set up correctly, BUT if i remove the default routes created by DHCP clients on both wan0 and wan1, there is not internet, this is not a suprise as i know that if a use /ip filter to add a routing mark on the default routes, they are not used, so i expected this to fail.

So this is the thing, if i only have routes with marks, this case "ISP1" and "ISP2", how i make it work? What im missing here?
 
Sob
Forum Guru
Forum Guru
Posts: 9188
Joined: Mon Apr 20, 2009 9:11 pm

Re: No internet if there is not a route whiout a routing mark

Thu Oct 10, 2019 5:36 am

You do need default route in main routing table for router itself, even if you don't actually use it and set routing for all output to use different routing table. The route doesn't even have to be real, it can point for example to empty bridge, it just needs to exist.

If you check the pretty pictures here:

https://wiki.mikrotik.com/wiki/Manual:Packet_Flow_v6

The second one, right half named "routing", you'll see that there's routing decision first and output (where you can set routing mark) is after that. And that is then handled by "routing adjustment" (in next picture), where the selected routing table is used.
 
shivansps
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 54
Joined: Fri Sep 22, 2017 1:18 am

Re: No internet if there is not a route whiout a routing mark

Thu Oct 10, 2019 8:43 pm

I ended up fixing it by adding another set of rules whiout the routing mark
/ip route
add distance=1 gateway=Host1 check-gateway=ping
add distance=2 gateway=Host2 check-gateway=ping
For the record, the wiki is not very clear what this
/ip route
add distance=1 gateway=Host1 routing-mark=ISP1 check-gateway=ping
add distance=2 gateway=Host2 routing-mark=ISP1 check-gateway=ping
and this
/ip route
add distance=1 gateway=Host2 routing-mark=ISP2 check-gateway=ping
add distance=2 gateway=Host1 routing-mark=ISP2 check-gateway=ping
does. The wiki example creates 2 routing marks, ISP1 and ISP2, ISP1 mark using GW1 and main and GW2 as failover, ISP2 mark uses GW2 as main and GW1 as failover, this is very usefull (i use ISP2 mark for wifi clients for example, and this ensures if GW2 is down, it will switch to use GW1).

But is really not needed.
/ip route
add dst-address=Host1 gateway=GW1 scope=10 comment=FAILOVER WAN0
add dst-address=Host2 gateway=GW2 scope=10 comment=FAILOVER WAN1
add distance=1 gateway=Host1 check-gateway=ping
add distance=2 gateway=Host2 check-gateway=ping
is all thats needed for a 2 WAN advanced failover to work.

I complemented it with this nice lease script i found on this forum to update the gateway IP as i have dynamic ips.
:local newgw [ip dhcp-client get [find interface="ether2-WAN1"] gateway];
:local routegw [/ip route get [find comment="FAILOVER WAN1"] gateway ];
:if ($newgw != $routegw) do={
     /ip route set [find comment="FAILOVER WAN1"] gateway=$newgw;
}