A second provider is added so that the office is not left without internet when the main link fails. A common mistake is that failover only happens when the cable is unplugged: if the link to the provider is up but there is no internet behind it, the router keeps sending everything into the "dead" channel. Here is how to make MikroTik switch on real internet reachability, balance load and answer incoming connections through the right provider.
The simple setup and its trap
The simplest scheme is two default routes with different distances:
/ip route add dst-address=0.0.0.0/0 gateway=10.1.1.1 distance=1 check-gateway=ping add dst-address=0.0.0.0/0 gateway=10.2.2.1 distance=2
The main route with the lower distance works while check-gateway gets replies from the gateway. But the provider's gateway often sits right in your building, or is just a modem, and it answers ping even when the provider's backbone is down. No failover happens.
The reliable setup: recursive routes
The idea is to check not the gateway but some host on the internet, and to check it through a specific provider:
- Pick a check address per provider, for example public DNS servers 77.88.8.8 and 1.1.1.1.
- Add a /32 route to the check address strictly through that provider's gateway, and behind it a blackhole route with a higher distance, so that when the link fails the check does not go through the other provider.
- Point the default route at the check address with
check-gateway=pingand atarget-scopehigher than the /32 route's scope: RouterOS will find the real gateway recursively.
/ip route
add dst-address=77.88.8.8/32 gateway=10.1.1.1 scope=10
add dst-address=77.88.8.8/32 blackhole distance=20
add dst-address=0.0.0.0/0 gateway=77.88.8.8 target-scope=11 \
check-gateway=ping distance=1
add dst-address=0.0.0.0/0 gateway=10.2.2.1 distance=2
This is RouterOS 7 syntax; in RouterOS 6, write type=blackhole instead of blackhole. Now the main route goes down when 77.88.8.8 stops answering through the first provider — that is, when the internet itself is gone. For reliability, use two check addresses per provider: one unreachable host should not switch the whole office.
Incoming connections through the same provider
If ports are forwarded on both links, or you connect to the router from outside at either address, replies must leave through the provider the request came in on. Otherwise the reply to a connection on the second address leaves through the first link, and the client drops it.
For this, incoming connections are marked in mangle (a connection-mark by the interface they arrived on), replies get a routing mark, and each provider gets its own routing table with a default route only through it. In RouterOS 7 tables are created explicitly: /routing table add name=isp2 fib.
Load balancing
In RouterOS 7, two default routes with the same distance form ECMP: connections are spread between the links, and each connection stays on its provider. This is not "adding speeds" for one download but spreading different connections. If the links differ a lot in speed, balancing can hurt: the slow link becomes the bottleneck for half of the users. Then a "main + backup" scheme is more reliable.
Balancing can surprise sites that tie a session to an IP address: banks and government services may log users out when requests come from one address, then another. A rule that sends such sites through the main link helps.
What else not to forget
- NAT on both interfaces: masquerade is needed for each WAN, otherwise not a single packet leaves through the second link.
- Interface lists. Add both WAN interfaces to the WAN list so the firewall protects both.
- Testing. Take the main link down not by unplugging the cable but, for example, by blocking the check address with an output rule — that way you test exactly the "link up, no internet" case.
Recursive routes, check addresses, ECMP, replies through the same provider and rollback in one script are built by the MikroTik dual WAN generator. To work out where a packet goes with complex rules, use the firewall packet path, and if you need the same on Cisco, there is the Cisco backup link with IP SLA.