WLAN primary, WAN failover - what route to take?

Hi all,

Not sure if I’m posting this in the right place - but it’s a combination of topics so I thought it would do well here. I’m also new to the Routerboard and RouterOS - so for give me if I ask stupid questions. Also completely new to network engineering - I’m an electro-mechanical engineer.

I have a DSL router/modem that broadcasts a WLAN and provides access to the internet. I’ve set up my Mikrotik hAP to connect to this WLAN using DHCP and which is set to automatically create a default route. It’s important to know that my WLAN on the DSL router HAS to be dynamic, as this solution is intended for installation on the clients’ network that I do not necessarily have access to (in terms of setting up a static IP), other than SSID and security profile.

I have also connected a 3G modem to the hAP via the USB port and setup a PPP client to connect to the internet via the 3G modem. This is also a dynamic IP provided by the ISP.

Now, I need to create a failover routing configuration. The scenario is that when there is no connection to the internet through the WLAN of the DSL router, the default route must switch to the 3G modem. When the connection to the internet through the WLAN of the DSL is available again, it needs to switch back to this.

I’ve tried a number of things including using Netwatch with a script pinging a host (google.com), trying to manually configure routes based on some guides I’ve found, but I can’t seem to get anything to work. Anything I seem to do in terms of the WLAN side seems to break that connection - ie if I set add default route to ‘no’ and create my own default route - it breaks. I guess it must have something to do with the DHCP client?

My two interfaces are called wlan1 and ppp-out1. I have a NAT masquerade for each. And a DHCP client on the wlan. I’ve set the default distance of wlan1 to 1 and the default distance of ppp-out1 to 2. My DSL modem’s IP address is 10.0.0.2 and wlan1 is currently leased 10.0.0.6.

Does anyone have any ideas as to which direction I should take in setting up this failover? Thanks in advance.

Hey, check this out:

Two gateways failover
This example explains how to use multiple gateways with one taking over when first fails. It begins with adding the gateways. Set bigger distance value for the secondary one, and check-gateway for the first one:

/ip route add gateway=192.168.1.1 check-gateway=ping
/ip route add gateway=192.168.2.1 distance=2
That’s all, there are no more steps!

The first gateway will begin as it’s distance is smaller (default 0); the check-gateway will make sure it’s up; when the ping will fail, it will disable the first gateway and the second will take over; when first one comes up, it will return to it’s function.

source: http://wiki.mikrotik.com/wiki/Two_gateways_failover