Backup internet for the office: two ISPs and automatic failover on MikroTik
How to set up a second internet connection so the office switches to it automatically and back again when the main provider recovers. Recursive routing on MikroTik, reachability checks and the pitfalls.
Alexei Sergeev3 min read
When an office loses internet today, almost everything stops: cloud accounting, CRM, telephony, email. Meanwhile, a second connection from another provider usually costs noticeably less than an hour of the whole company standing idle. But a second cable in the rack solves nothing on its own: the switchover has to happen automatically and correctly.
Why checking the gateway is not enough
The simplest option is two default routes with different distances and check-gateway=ping. The problem is that this only checks whether the provider's nearest gateway is reachable. A common situation: the gateway responds, but the internet beyond it does not work because the outage is deeper in the provider's network. The router considers the link healthy, and the office stays offline.
It is better to check the reachability of something beyond the provider, such as a public DNS server, and to do it through a specific link. RouterOS uses recursive routing for this.
Recursive routes: configuration
The idea: a route to a chosen external address (a different one for each provider) is set strictly via that provider's gateway. The default route then points not at the gateway but at that external address. If the address stops answering ping, the default route becomes inactive and traffic moves to the backup link.
With this setup, the return happens on its own: as soon as the check address answers through the first provider again, the route with the lower distance becomes active. Connections that are already open will keep using the backup link for a while, which is normal.
Inbound connections and VPN
If people connect to the office from outside (VPN for remote staff, access to a server), you need to plan which address they connect to and how replies go back through the same link the request came in on. This is solved with connection marking (mangle) and separate routing tables, a topic for a separate article. For a site-to-site VPN, it is convenient to build tunnels over both links.
A metered backup link
If the backup is an LTE modem with limited traffic, it is worth limiting what goes through it: for example, allow only work services and block operating system updates and cloud sync of large files.
How to check that it works
Setting up failover is half the job. The other half is testing it under controlled conditions, not during a real outage. Here is what I do:
Unplug the main provider's cable and time how long a test computer loses and regains connectivity.
Simulate the gateway-up-but-no-internet case: block ping to the check address on the router and make sure the route becomes inactive.
Check that telephony and VPN work, since they are the most sensitive to a switchover.
Set up a notification on switchover: the office should not run on the backup link for months without knowing it.
Link redundancy is one of the tasks within network infrastructure work. If the infrastructure is maintained on an ongoing basis, it makes sense to include failover testing in scheduled maintenance.
Want your office not to depend on a single provider?
Tell me which links you have now and what is critical for your work. I will propose a redundancy scheme and test it before handover.
Why a flat network where every device sees every other one is the main source of trouble in a small office, and how to split it into VLANs on MikroTik with RouterOS 7: the layout, bridge configuration, firewall rules an…
How to connect two offices and remote employees with WireGuard on MikroTik running RouterOS 7: the addressing plan, tunnel and route configuration, firewall rules and what to test before handover.
Dead zones, drops when walking between rooms and slowness in the meeting room: I go through the common causes of office Wi-Fi problems and how I design a wireless network so that it works reliably.
Read →
This site can use Yandex Metrica for anonymised visit statistics. Allow it?
Learn more