Dual-WAN Failover on MikroTik: check-gateway vs Recursive Routing
Why a backup default route with a higher distance is not always enough, and how recursive routes detect an upstream failure that check-gateway misses.
Problem
You have two ISPs. When the primary ISP stops passing traffic, the router keeps sending everything to it — your users are offline even though the backup link is fine.
Symptoms
- The primary default route stays active while the Internet is down.
- Failover only happens when the cable is unplugged.
Likely causes
check-gateway=pingonly tests the next hop. If the ISP's gateway still answers but its upstream is broken, the route never fails.- Both routes have the same distance, or the backup route is missing.
Prerequisites
- Two working WAN links. This guide uses documentation addresses: ISP1 gateway
203.0.113.1, ISP2 gateway198.51.100.1. - NAT (masquerade) configured for both WAN interfaces.
Warning: Route changes affect all traffic. Apply them in a maintenance window, with Safe Mode on.
Solution
Option A — simple: distance plus check-gateway
Good when failures usually mean the link itself goes down.
/ip route
add dst-address=0.0.0.0/0 gateway=203.0.113.1 distance=1 check-gateway=ping comment="WAN1 primary"
add dst-address=0.0.0.0/0 gateway=198.51.100.1 distance=2 comment="WAN2 backup"Option B — recursive: test a host beyond the ISP
Route a well-known public address only through ISP1, then point the primary default route at that address. If the address becomes unreachable through ISP1, the primary route goes inactive and the backup takes over.
/ip route
add dst-address=1.1.1.1/32 gateway=203.0.113.1 scope=10 comment="WAN1 probe host"
add dst-address=0.0.0.0/0 gateway=1.1.1.1 target-scope=11 check-gateway=ping distance=1 comment="WAN1 primary (recursive)"
add dst-address=0.0.0.0/0 gateway=198.51.100.1 distance=2 comment="WAN2 backup"The target-scope=11 on the default route lets RouterOS resolve the gateway 1.1.1.1 through the host route, whose scope=10 is lower.
Verification
/ip route print where dst-address=0.0.0.0/0The primary route should be active (A flag). To test, block ICMP to the probe host on the ISP1 side (or disconnect the ISP1 upstream). Within a few ping intervals the primary route should become inactive and the backup should take over.
Common errors
- The probe host is also used by users. Traffic to
1.1.1.1will always go via ISP1. Pick a probe address your users do not depend on. - Recursive route never becomes active: check that
target-scopeon the default route is greater than or equal to thescopeof the host route. - Failover works but sessions break: existing connections are tied to the old WAN's NAT address. That is expected; new connections use the backup.
Rollback
/ip route remove [find comment~"WAN1"]
/ip route add dst-address=0.0.0.0/0 gateway=203.0.113.1 comment="WAN1 primary"This topic is covered hands-on in MTCRE — MikroTik Certified Routing Engineer.
View MTCRE