failover with 3 ISP without balancing

Mikrotik RB2011UiAS-RM

RouterOS ver. 6.6

We have 3 different internet connections, the port configuration looks like this:

ethernet1 WAN1 – PPPOE connection, static IP
ethernet2 WAN2 – static IP
ethernet3 WAN3 – 3g internet connection switched to 3G router, IP: 192.168.4.4

ethernet4 – not in use
ethernet5 – not in use

ethernet6 – 192.168.1.0 subnet
ethernet7 – 192.168.2.0 subnet
ethernet8 – 192.168.3.0 subnet
ethernet9 – ethernet6
ethernet10 – ethernet6

bridge-local 192.168.88.1

My question is, can we do failover with this 3 WAN connections, without using balancing? If WAN1 is unaccessable, it should switch to WAN2, and if both WAN1 and WAN2 are down, it should switch to WAN3 3g. When WAN1 or WAN2 is up, it should switch back from 3g router.

Is it possible to do this without writing a script, or somebody already did some configuration similar like this? Can somebody send me a link with a similar configuration?

No script necessary.
/ip route
add check-gateway=ping distance=10 gateway=10.1.1.1
add check-gateway=ping distance=20 gateway=10.2.2.1
add check-gateway=ping distance=30 gateway=10.3.3.1

/ip firewall nat
add chain=srcnat chain=srcnat out-interface=WAN1 to-addresses=10.1.1.2
add chain=srcnat chain=srcnat out-interface=WAN2 to-addresses=10.2.2.2
add chain=srcnat chain=srcnat out-interface=WAN3 to-addresses=10.3.3.2I know you have static IPs, but in the event that someone would need to do this with dynamic WAN addresses, just run a script periodically to check your WAN IP(s) and update your NAT rule(s).

Just to be clear, if you have two or more ISP’s coming in and you want them configured for weight based failover…

The only way RouterOS will support this is by setting a static IP and distance, or if dynamic WAN addresses you must run a script to periodically check for a new address and update the route and NAT table appropriately.

Correct?

If yes, is there a reason the distance can’t be set on a dynamically assigned IP? (beyound RouterOS won’t let you)

Thanks!

Yes, with static routes, I believe this would be the only way. To disable a gateway, you’ll need to use the check-gateway option. Without a valid GW IP, this won’t work, and the route will not fail over to the next gateway.

RouterOS will not let you set the distance on a route installed by the dhcp client. The DHCP client in a generic Linux box does have the ability to run a script, which would allow you to do so.

It would be nice if MT would have a hook in the dhcp client to run a script. Useful not only for setting route information, but would also be a nice place for poeple to update their dynamic DNS servers and update any DST NAT rules.