Use a USB modem for backup Internet on a Mikrotik router.
I received as SMS from my dad:
Internet out for over 12 hrs. Have you ever set up Mikrotik with 3G modem?
I’d convinced my dad to replace an ageing (and occasionally faulty) router with a Mikrotik device a while back. He had purchased a hAP, and configured it based on my Mikrotik home router article. I’d reviewed what he did and tweaked a few things. And it’s been running quite smoothly since then. But even the best router can’t do much when there’s no Internet to route!
Except he was using a 3G USB Modem rather than an Android phone, so it didn’t quite work as nicely as I’d hoped.
Document and configure my dad’s router to allow him to use a 3G / LTE USB modem as a backup Internet connection if his Optus cable connection fails. (And maybe help a few other people on the Internet as well)!
Unlike my holiday LTE setup, failover will be important: automatic will be preferred, but outages aren’t very frequent, so simple manual steps will be allowed.
- A Mikrotik router with USB port,
- A supported USB 3G / LTE modem (see peripherals and supported hardware)
If your modem doesn’t work, it will be a pain to troubleshoot on your router. So double check it connects successfully in a more supported environment (eg: Windows laptop).
My dad is using a Huawei E1762 USB 3G modem. Which has minimal documentation on the Internet.
Depending on your router you may need a USB adapter cable. My dad’s hAP has a full size USB port, so he just plugged it in.
Check in System -> Resources -> USB for the modem you just connected. If there’s nothing there, it may not be supported and you’ll need to find an alternative.
My dad’s modem is a 3G device, so he created a new PPP Client in Interfaces -> New -> PPP Client.
You may need to set an APN, username or password (check with your service provider for this information); dad’s using an Optus service so his APN is
The Status should change to waiting for packets…, then link established and finally connected.
If you have a newer and faster LTE / 4G modem, an LTE interface should automatically be created. However, you may still need to set an APN, username or password.
You should also set the default route distance to
This will force the router to prefer your primary link over the 3G / LTE one.
At this point we should have a working cellular interface. You can test it by disabling your main Internet interface (eg: Cable / ADSL / Ethernet / whatever) temporarily (remember to turn safe mode on before you accidentally delete it!!). Your Internet should still work and you should see activity on the PPP / LTE interface.
You can use Tools -> Ping to test connectivity from the router itself (eg: to
IP -> Routes
You should see two default routes. Your router will prefer the primary connection (ie: cable, ADSL, etc) to the cellular one because it has a smaller distance.
However, both the primary and cellular interfaces will always be “up”, as far as routing is concerned (because the ethernet cable is plugged in). That is, even when your primary interface service does down, the router will keep trying to send traffic over your cable / ADSL / fibre link (even when the packets can’t go anywhere).
To switch over to the cellular backup interface, you should disable your primary interface. (And remember to re-enable it when it’s working again, of course).
This is a slightly manual process. However, if your primary interface is very reliable and you don’t really mind a few minutes down time while someone notices the Internet has dropped, logs into your router and clicks disable, then it is perfectly functional. (My dad prefers this approach, because cellular data is an order of magnitude more expensive in Australia, and he wants to know when he’s switched over to 3G).
But we can automate the switch from primary to backup interface (and back again) using a few simple routing rules. Be warned: this assumes a particular IP address as the default gateway; it is not picking it up automatically from DHCP.
We need to set the Check Gateway option to
ping, so the router can detect when a link has gone down.
Unfortunately, the default route created from DHCP does not let us do that - all fields are read only.
So, make a copy the default route.
Set Check Gateway to
And then disable this route.
Next, hop over to IP -> DHCP Client and set Add Default Route to
Your primary interface’s dynamic default route will disappear.
Back to the route table and enable the manual default route. Now should now have 2 routes to the Internet: primary via cable / ADSL / whatever, and secondary via 3G / LTE.
My dad simulated an Internet failure by turning off his cable modem (but not removing the ethernet cable). The router sees the ethernet port as still connected, but it can’t actually reach the Internet. It takes about 30 seconds for the router to notice and switch to routing over the backup 3G interface. After plugging the cable back in, it took another 30 seconds to switch back to the primary cable interface (mostly the cable modem sorting itself out).
Important: All this assumes your Internet gateway does not change. That is, we just hard coded a default gateway into your router. In other words, if your gateway ever changes your Internet will break and you’ll probably forget to check the route table. You should only do this if you have a static IP address, and even then be very wary.
We’ve followed the simple failover configuration, but if you have more complex requirements or more than 2 WAN links, you may want to consider a more advanced failover configuration. And a forum post with further failover information.
You can now have your Mikrotik router configured with a backup WAN interface using a 3G or LTE USB modem. And some very simple routing rules to switch to the backup link if the primary fails. (Or, you can just disable the primary interface).