Skip to main content

๐ŸŒ Failover Methods

This guide explains four distinct failover strategies in MikroTik for multi-ISP configurations, each with different mechanisms, latency profiles, and use cases. Understanding the flow and trade-offs helps you choose the right approach for your network topology.

info

Key Takeaway: Choose failover based on gateway complexity. Simple networks use check-gateway, multi-marked traffic uses route rules, recursive routes handle advanced topologies, and netwatch provides scripting flexibility for custom logic.


Prerequisitesโ€‹

โœ… MikroTik RouterOS v6.45+ (all methods)
โœ… Two or more ISP gateways with known IPs (e.g., 192.168.1.1, 192.168.1.2)
โœ… Ability to SSH into router or access Winbox
โœ… Understanding of routing tables and gateway concepts
โœ… Test hosts accessible via each ISP (e.g., 1.1.1.1, 1.1.1.2)


Failover Detection Flowโ€‹

All methods rely on periodic health checks. Here's the universal flow:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Traffic Sent โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Which Failover Method Active? โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ โ‘  check-gateway โ†’ Built-in ping โ”‚
โ”‚ โ‘ก route rules โ†’ Built-in ping โ”‚
โ”‚ โ‘ข recursive โ†’ Built-in ping โ”‚
โ”‚ โ‘ฃ netwatch โ†’ External monitor โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Health Check โ”‚
โ”‚ (Ping Probe) โ”‚
โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”˜
โ”‚ โ”‚
Response No Response
(OK) (FAIL)
โ”‚ โ”‚
โ–ผ โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Use โ”‚ โ”‚ Route Status โ”‚
โ”‚ ISP โ”‚ โ”‚ Update? โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
(depends on method)

Method 1: Check-Gateway (Passive Built-In)โ€‹

How It Worksโ€‹

The router continuously pings a gateway IP and automatically disables the route if the gateway doesn't respond. When the gateway recovers, the route re-enables.

Flow Diagram:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Primary Route (ISP-1, distance=1) โ”‚
โ”‚ /ip route with check-gateway="ping" โ”‚
โ”‚ Destination: 0.0.0.0/0 โ”‚
โ”‚ Gateway: 192.168.1.1 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”˜
โ”‚ โ”‚
Every ~3s When Disabled
Pings 192.168.1.1 โ”‚
โ”‚ โ”‚
โ”œโ”€ ICMP Response โ–ผ
โ”‚ Route Stays ACTIVE โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ โ”‚ ISP-1 Unavailableโ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚
โ”œโ”€ No Response (3 failed probes) โ”‚
โ”‚ Route Auto DISABLED Secondary Route
โ”‚ (ISP-2, distance=2)
โ”‚ Takes Over
โ”‚
โ””โ”€ Recovery: Response Received
Route Re-enabled

Configurationโ€‹

Option A: Terminal

/ip route
add dst-address="0.0.0.0/0" target-scope="10" distance="1" gateway="192.168.1.1" \
comment="ISP-1" check-gateway="ping" scope="30" routing-table=main
add dst-address="0.0.0.0/0" target-scope="10" distance="2" gateway="192.168.1.2" \
comment="ISP-2" check-gateway="ping" scope="30" routing-table=main

Option B: Winbox

  1. Navigate to: IP โ†’ Routes
  2. Click + to add first route:
    • Dst. Address: 0.0.0.0/0
    • Gateway: 192.168.1.1
    • Distance: 1
    • Check Gateway: ping
    • Comment: ISP-1
  3. Click + to add second route:
    • Dst. Address: 0.0.0.0/0
    • Gateway: 192.168.1.2
    • Distance: 2
    • Check Gateway: ping
    • Comment: ISP-2

Key Parameters Explainedโ€‹

ParameterValueMeaning
check-gatewaypingUse ICMP echo as health probe
distance1, 2, 3...Route priority (lower = preferred)
target-scope10Scope flag for route categorization
scope30Route is managed by user/admin

Pros & Consโ€‹

ProsCons
โœ… Simpleโ€”no scripting neededโŒ Ping probe latency ~100-300ms
โœ… Built-in to RouterOSโŒ Cannot distinguish between ISP failure vs. gateway failure
โœ… Minimal CPU overheadโŒ No custom logic (always uses distance metric)
โœ… Works with any gatewayโŒ Probe target must be gateway IP itself

Use Caseโ€‹

Best for: Simple dual-ISP setups where each ISP provides a local gateway and both are directly reachable via ping.


Method 2: Route Rules + Check-Gateway (Marked Traffic)โ€‹

How It Worksโ€‹

Combines check-gateway with policy-based routing. Traffic is marked with routing marks, then routed to specific ISPs via separate routing tables. If the ISP in the primary table fails, traffic fails over to the secondary.

Flow Diagram:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Incoming Traffic โ”‚
โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚
โ–ผ โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Has Routing Mark? โ”‚ โ”‚ No Mark = Use โ”‚
โ”‚ (via mangle/filter) โ”‚ โ”‚ Default Table โ”‚
โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ (main) โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”œโ”€ Mark=to-isp1 โ”‚
โ”‚ โ–ผ โ”‚
โ”‚ /ip route rule lookup to-isp1 table โ”‚
โ”‚ โ–ผ โ”‚
โ”‚ Query: to-isp1 Routing Table โ”‚
โ”‚ ISP-1 Primary (distance=1) โ”‚
โ”‚ Check-gateway status? โ”‚
โ”‚ โ”œโ”€ Active โ†’ Use ISP-1 โ”‚
โ”‚ โ””โ”€ Down โ†’ No route found (packet drop) โ”‚
โ”‚ โ”‚
โ”œโ”€ Mark=to-isp2 โ”‚
โ”‚ โ–ผ โ”‚
โ”‚ /ip route rule lookup to-isp2 table โ”‚
โ”‚ โ–ผ โ”‚
โ”‚ Query: to-isp2 Routing Table โ”‚
โ”‚ ISP-2 Primary (distance=1) โ”‚
โ”‚ Check-gateway status? โ”‚
โ”‚ โ”œโ”€ Active โ†’ Use ISP-2 โ”‚
โ”‚ โ””โ”€ Down โ†’ No route found (packet drop) โ”‚
โ”‚ โ”‚
โ””โ”€ No Mark โ”‚
โ–ผ โ”‚
Uses default route (main table) โ†โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
ISP-1 Primary (distance=1)
Check-gateway status?
โ”œโ”€ Active โ†’ Use ISP-1
โ””โ”€ Down โ†’ Fallback ISP-2 (distance=2)

Configurationโ€‹

Option A: Terminal

# Step 1: Create routes in each ISP-specific table
/ip route
add dst-address="0.0.0.0/0" target-scope="10" distance="1" gateway="192.168.1.1" \
comment="ISP-1" check-gateway="ping" scope="30" routing-table=to-isp1
add dst-address="0.0.0.0/0" target-scope="10" distance="1" gateway="192.168.1.2" \
comment="ISP-2" check-gateway="ping" scope="30" routing-table=to-isp2

# Step 2: Create default routes in main table (fallback)
add dst-address="0.0.0.0/0" target-scope="10" distance="1" gateway="192.168.1.1" \
comment="ISP-1-main" check-gateway="ping" scope="30" routing-table=main
add dst-address="0.0.0.0/0" target-scope="10" distance="2" gateway="192.168.1.2" \
comment="ISP-2-main" check-gateway="ping" scope="30" routing-table=main

# Step 3: Create route rules to direct marked traffic
/ip route rule
add action=lookup disabled=no routing-mark=to-isp1 table=to-isp1
add action=lookup disabled=no routing-mark=to-isp2 table=to-isp2
add action=lookup-only-in-table disabled=no routing-mark=to-isp1 table=main
add action=lookup-only-in-table disabled=no routing-mark=to-isp2 table=main

# Step 4: Mark traffic with mangle rules (example: mark based on src-address)
/ip firewall mangle
add chain=prerouting src-address=192.168.100.0/24 action=mark-routing \
new-routing-mark=to-isp1 passthrough=yes comment="Subnet-1 uses ISP-1"
add chain=prerouting src-address=192.168.101.0/24 action=mark-routing \
new-routing-mark=to-isp2 passthrough=yes comment="Subnet-2 uses ISP-2"

Option B: Winbox

  1. Create ISP-specific routing tables:

    • IP โ†’ Routes โ†’ Click Routes (empty list shows main table)
    • Right-click, New โ†’ Create route with Routing Table: to-isp1 (repeat for to-isp2)
  2. Create route rules:

    • IP โ†’ Route Rules โ†’ Click +
    • Action: lookup
    • Routing Mark: to-isp1
    • Table: to-isp1
    • Repeat for to-isp2
  3. Mark traffic with mangle:

    • IP โ†’ Firewall โ†’ Mangle โ†’ Click +
    • Chain: prerouting
    • Src. Address: 192.168.100.0/24
    • Action: mark-routing
    • New Routing Mark: to-isp1
    • Repeat for other subnets

Key Parameters Explainedโ€‹

ParameterMeaning
routing-table=to-isp1Define alternative routing table (not default main)
routing-mark=to-isp1Lookup routes only in this table
new-routing-mark=to-isp1Mark packets for specific ISP routing table
action=lookup-only-in-tableRestrict lookup to specified table only

Pros & Consโ€‹

ProsCons
โœ… Per-subnet ISP assignment (A to ISP-1, B to ISP-2)โŒ Complex configuration (multiple tables + rules + mangle)
โœ… Traffic isolation by routing tableโŒ Requires traffic marking rules
โœ… Works with check-gatewayโŒ Hard to debug (traffic must match mangle rules)
โœ… Predictable failover per routeโŒ Main table fallback still needed

Use Caseโ€‹

Best for: Enterprise networks with multiple subnets requiring different ISP assignments (e.g., VoIP via ISP-1, data via ISP-2).


Method 3: Recursive Routing (Advanced)โ€‹

How It Worksโ€‹

Creates a chain of dependencies between routes. Primary routes use external IPs (1.1.1.1, 1.1.1.2) as gateways, which are themselves resolved via local gateway routes. If the external IP becomes unreachable, the primary route fails, triggering failover.

Flow Diagram:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Packet to Destination (0.0.0.0/0) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Route Lookup: 0.0.0.0/0 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Primary: 0.0.0.0/0 via 1.1.1.1 โ”‚
โ”‚ Distance: 1, check-gateway: ping โ”‚
โ”‚ Secondary: 0.0.0.0/0 via 1.1.1.2 โ”‚
โ”‚ Distance: 2, check-gateway: ping โ”‚
โ””โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Recursive Lookup: Where is 1.1.1.1? โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ /ip route find dst-address=1.1.1.1 โ”‚
โ”‚ Result: 1.1.1.1/32 via 192.168.1.1 โ”‚
โ”‚ (check-gateway="ping" on this route) โ”‚
โ””โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ”œโ”€ ICMP Reply to 1.1.1.1 โœ“ (via 192.168.1.1)
โ”‚ โ†’ Use primary route (0.0.0.0/0 via 1.1.1.1)
โ”‚
โ””โ”€ No Reply to 1.1.1.1 โœ— (ISP-1 down)
Recursive route 1.1.1.1/32 DISABLED
โ†’ Cannot reach 1.1.1.1 gateway
โ†’ Primary route becomes INVALID
โ†’ Failover to secondary (0.0.0.0/0 via 1.1.1.2)
โ–ผ
Recursive Lookup: Where is 1.1.1.2?
Result: 1.1.1.2/32 via 192.168.1.2
Ping 1.1.1.2 successful โœ“ (via ISP-2)
โ†’ Use secondary route

Configurationโ€‹

Option A: Terminal

/ip route
# Step 1: Primary route using external IP 1.1.1.1 as gateway
add dst-address="0.0.0.0/0" target-scope="30" distance="1" gateway="1.1.1.1" \
comment="ISP-1" check-gateway="ping" scope="30" routing-table=main

# Step 2: Secondary route using external IP 1.1.1.2 as gateway
add dst-address="0.0.0.0/0" target-scope="30" distance="2" gateway="1.1.1.2" \
comment="ISP-2" check-gateway="ping" scope="30" routing-table=main

# Step 3: Recursive routes defining how to reach the external gateways
add dst-address="1.1.1.1" target-scope="10" distance="1" gateway="192.168.1.1" \
comment="ISP-1-Check" check-gateway="ping" scope="30" routing-table=to-isp1

add dst-address="1.1.1.2" target-scope="10" distance="1" gateway="192.168.1.2" \
comment="ISP-2-Check" check-gateway="ping" scope="30" routing-table=to-isp2

Option B: Winbox

  1. IP โ†’ Routes โ†’ Click +

    • Dst. Address: 0.0.0.0/0
    • Gateway: 1.1.1.1 (external DNS/public IP)
    • Distance: 1
    • Check Gateway: ping
    • Comment: ISP-1
  2. IP โ†’ Routes โ†’ Click + (second route)

    • Dst. Address: 0.0.0.0/0
    • Gateway: 1.1.1.2
    • Distance: 2
    • Check Gateway: ping
    • Comment: ISP-2
  3. IP โ†’ Routes โ†’ Click + (recursive route 1)

    • Dst. Address: 1.1.1.1/32
    • Gateway: 192.168.1.1
    • Check Gateway: ping
    • Comment: ISP-1-Check
  4. IP โ†’ Routes โ†’ Click + (recursive route 2)

    • Dst. Address: 1.1.1.2/32
    • Gateway: 192.168.1.2
    • Check Gateway: ping
    • Comment: ISP-2-Check

Key Conceptโ€‹

Recursive routes create a dependency chain:

  • Route A (0.0.0.0/0 via 1.1.1.1) depends on Route B (1.1.1.1/32 via 192.168.1.1)
  • If Route B fails health check โ†’ Route B disabled
  • Route A cannot find gateway 1.1.1.1 โ†’ Route A fails
  • Failover to Route C (0.0.0.0/0 via 1.1.1.2) automatically

Pros & Consโ€‹

ProsCons
โœ… Natural failover chain (no extra rules needed)โŒ Requires external IPs as probes (e.g., DNS: 1.1.1.1)
โœ… Handles complex topologies with multiple hopsโŒ Probe target must be reachable via primary ISP
โœ… Automatic dependency resolutionโŒ Latency depends on recursive lookup depth
โœ… Good for ISPs that block direct pings to gatewayโŒ Difficult to debug (need traceroute to understand)

Use Caseโ€‹

Best for: Complex ISP setups where gateway IP doesn't respond to ping, so you use public DNS IPs (1.1.1.1) or other public services as probe targets.


Method 4: Netwatch (Manual Scripting)โ€‹

How It Worksโ€‹

An external monitoring tool periodically checks a host, then runs custom scripts if the host goes down or recovers. Gives you complete control over failover logicโ€”disable/enable routes, trigger alerts, execute any RouterOS command.

Flow Diagram:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Netwatch Monitoring Loop (every 5s) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Ping Target: 1.1.1.1 (ISP-1 probe) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚
ICMP OK No Response
โ”‚ โ”‚
โ–ผ โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Host UP โ”‚ โ”‚ Host DOWN (3 fails)โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ โ”‚
โ–ผ โ–ผ
Execute: Execute:
up-script down-script
โ”‚ โ”‚
โ”‚ โ”œโ”€ /ip route disable [find comment="ISP-1"]
โ”‚ โ”‚ โ””โ”€ All ISP-1 routes now DISABLED
โ”‚ โ”‚
โ”‚ โ”œโ”€ Optional: Log to file
โ”‚ โ”‚ โ””โ”€ /log warning "ISP-1 Down"
โ”‚ โ”‚
โ”‚ โ””โ”€ Optional: Send email alert
โ”‚ โ””โ”€ /tool send-email ...
โ”‚
โ””โ”€ /ip route enable [find comment="ISP-1"]
โ””โ”€ All ISP-1 routes now RE-ENABLED
(Router immediately tries ISP-1 routes)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Result: Failover or Failback โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ ISP-1 Down (no route) โ”‚
โ”‚ โ†’ Traffic uses ISP-2 (distance=2) โ”‚
โ”‚ โ”‚
โ”‚ ISP-1 Recovers (route re-enabled) โ”‚
โ”‚ โ†’ Traffic back to ISP-1 (distance=1) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Configurationโ€‹

Option A: Terminal

# Step 1: Create default routes (ISP-1 primary, ISP-2 secondary)
/ip route
add dst-address="0.0.0.0/0" target-scope="10" distance="1" gateway="192.168.1.1" \
comment="ISP-1" check-gateway="none" scope="30" routing-table=main
add dst-address="0.0.0.0/0" target-scope="10" distance="2" gateway="192.168.1.2" \
comment="ISP-2" check-gateway="none" scope="30" routing-table=main

# Step 2: Create recursive routes for netwatch probes
add dst-address="1.1.1.1" target-scope="10" distance="1" gateway="192.168.1.1" \
comment="ISP-1-probe" scope="30" routing-table=to-isp1
add dst-address="1.1.1.2" target-scope="10" distance="1" gateway="192.168.1.2" \
comment="ISP-2-probe" scope="30" routing-table=to-isp2

# Step 3: Create netwatch monitors with down/up scripts
/tool netwatch
add host="1.1.1.1" interval="5s" timeout="3s" \
down-script="/ip route disable [find comment=\"ISP-1\"]" \
up-script="/ip route enable [find comment=\"ISP-1\"]" \
comment="ISP-1"

add host="1.1.1.2" interval="5s" timeout="3s" \
down-script="/ip route disable [find comment=\"ISP-2\"]" \
up-script="/ip route enable [find comment=\"ISP-2\"]" \
comment="ISP-2"

Option B: Winbox

  1. Create routes (WITHOUT check-gateway):

    • IP โ†’ Routes โ†’ Click +
    • Dst. Address: 0.0.0.0/0
    • Gateway: 192.168.1.1
    • Distance: 1
    • Comment: ISP-1
    • Check Gateway: none (important: let netwatch handle it)
  2. Create netwatch monitors:

    • Tools โ†’ Netwatch โ†’ Click +
    • Host: 1.1.1.1 (external IP to probe)
    • Interval: 5s
    • Down Script:
      /ip route disable [find comment="ISP-1"]
    • Up Script:
      /ip route enable [find comment="ISP-1"]
    • Comment: ISP-1
    • Click + (add second netwatch for ISP-2)

Key Parameters Explainedโ€‹

ParameterMeaning
hostExternal IP to ping (e.g., public DNS 1.1.1.1)
intervalProbe frequency (default 60s, shown as 5s for fast failover)
timeoutFail after N seconds of no response
down-scriptRouterOS commands executed when host unreachable
up-scriptRouterOS commands executed when host recovers
check-gateway="none"Disable built-in checks; let netwatch manage routes

Advanced Script Exampleโ€‹

With Logging & Email Alert:

/tool netwatch
add host="1.1.1.1" interval="5s" timeout="3s" \
down-script="/log warning \"ISP-1 Down\"; \
/ip route disable [find comment=\"ISP-1\"]; \
/tool send-email to=\"admin@example.com\" subject=\"ISP-1 Failover\" body=\"ISP-1 is down, using ISP-2\"" \
up-script="/log info \"ISP-1 Up\"; \
/ip route enable [find comment=\"ISP-1\"]; \
/tool send-email to=\"admin@example.com\" subject=\"ISP-1 Recovered\" body=\"ISP-1 is back online\"" \
comment="ISP-1"

Pros & Consโ€‹

ProsCons
โœ… Complete control over failover logicโŒ Requires explicit scripting (not automatic)
โœ… Can execute any RouterOS command on failureโŒ More CPU overhead (external monitoring process)
โœ… Can send alerts/notificationsโŒ Requires netwatch service running
โœ… Flexible probe targets (any external IP)โŒ Failover delay = netwatch interval + timeout
โœ… Easy to debug (scripts visible in GUI)โŒ Misconfigured scripts can break routing

Use Caseโ€‹

Best for: Networks needing custom alerting, logging, or complex failover actions (e.g., disable VPN route on ISP-1 failure, reset firewall nat rules, trigger backup systems).


Comparison Tableโ€‹

FeatureCheck-GatewayRoute RulesRecursiveNetwatch
Setup Complexityโญ Very Simpleโญโญโญ Complexโญโญ Moderateโญโญ Moderate
Failover Latency~100-300ms~100-300ms~100-300ms~5-15s (configurable)
CPU Usage๐Ÿ’š Very Low๐Ÿ’š Very Low๐Ÿ’š Very Low๐ŸŸก Moderate
Scripting SupportโŒ NoโŒ NoโŒ Noโœ… Full
Per-Subnet ISP ControlโŒ Noโœ… YesโŒ NoโŒ No
Dependency ChainsโŒ NoโŒ Noโœ… YesโŒ No
Custom LogicโŒ NoโŒ NoโŒ Noโœ… Yes
Alerting/LoggingโŒ NoโŒ NoโŒ Noโœ… Yes
Best ForSimple dual-ISPMulti-subnet per-ISPComplex topologiesCustom failover actions

Verification Stepsโ€‹

For All Methods:โ€‹

# 1. Check active routes
/ip route print where dst-address="0.0.0.0/0"

# 2. Verify route status (ACTIVE = enabled, X = disabled)
/ip route print where dst-address="0.0.0.0/0" detail

# 3. Test failover by simulating ISP-1 down (temporarily disable)
/ip route disable [find comment="ISP-1"]

# 4. Verify traffic now routes via ISP-2
/ip route print

# 5. Re-enable ISP-1 (failback)
/ip route enable [find comment="ISP-1"]

# 6. Check routing mark for marked traffic (Method 2 only)
/ip route rule print

# 7. For netwatch, view monitoring status
/tool netwatch print

Test Packet Path:โ€‹

# Trace route through active ISP
/ip route print where dst-address="0.0.0.0/0"
# Note the first active route (lowest distance)

# Ping external host to verify ISP connectivity
/ping 8.8.8.8 count=5

# For recursive routes, check if probe target is reachable
/ip route print where dst-address="1.1.1.1"

Troubleshootingโ€‹

IssueCauseSolution
Route remains DISABLED after ISP recoversCheck-gateway still sees host down, or netwatch is disabledManually enable: /ip route enable [find comment="ISP-1"], check probe target (1.1.1.1 reachable?), verify gateway IP (192.168.1.1 responds to ping?)
Both routes show ACTIVE but traffic still failsDistance metric incorrect or both gateways downVerify distance values (lower = preferred). Ping both gateways: /ping 192.168.1.1 and /ping 192.168.1.2. Check if gateway IPs are correct.
Failover takes too long (>30 seconds)Check-gateway interval too long, or netwatch timeout too highReduce check-gateway ping interval in route (default ~3s), reduce netwatch interval (e.g., 5s instead of 60s), reduce timeout (e.g., 3s).
Route rules not directing traffic to ISP-2Mangle rule not matching traffic, or route-rule action incorrectVerify mangle rule matches source address: /ip firewall mangle print, check routing-mark is applied: /ip firewall mangle print stats. Verify route rule has action=lookup: /ip route rule print.
Netwatch scripts not executingNetwatch disabled, or script syntax errorEnable netwatch: /tool netwatch enable [find comment="ISP-1"], test script manually: copy down-script content and run, check RouterOS logs for errors: /log print.
Recursive route not working (gateway unreachable)Recursive probe target (1.1.1.1) not responding, or recursive route misconfiguredVerify recursive route exists: /ip route print where dst-address="1.1.1.1", ping probe target directly: /ping 1.1.1.1, check if recursive route via ISP is active.
Traffic uses wrong ISP (not preferred)Distance value too high on primary, or secondary route has lower distanceVerify primary distance = 1, secondary = 2: /ip route print. Disable secondary route, test traffic, re-enable.

Advanced Optionsโ€‹

1. Combined Approach: Check-Gateway + Netwatchโ€‹

Use built-in check-gateway for automatic failover, and netwatch for alerting:

# Routes use check-gateway (fast failover)
/ip route
add dst-address="0.0.0.0/0" distance="1" gateway="192.168.1.1" \
check-gateway="ping" comment="ISP-1"
add dst-address="0.0.0.0/0" distance="2" gateway="192.168.1.2" \
check-gateway="ping" comment="ISP-2"

# Netwatch adds logging & alerts (no disable/enable script)
/tool netwatch
add host="1.1.1.1" interval="10s" \
down-script="/log warning \"ISP-1 health check failed\"; \
/tool send-email to=\"admin@example.com\" subject=\"ISP-1 Degraded\"" \
comment="ISP-1-Alert-Only"

2. Multi-Tier Failover (3+ ISPs)โ€‹

/ip route
add dst-address="0.0.0.0/0" distance="1" gateway="192.168.1.1" \
check-gateway="ping" comment="ISP-1"
add dst-address="0.0.0.0/0" distance="2" gateway="192.168.1.2" \
check-gateway="ping" comment="ISP-2"
add dst-address="0.0.0.0/0" distance="3" gateway="192.168.1.3" \
check-gateway="ping" comment="ISP-3"

Distance values create a failover chain: ISP-1 โ†’ ISP-2 โ†’ ISP-3.

3. Conditional Failover Based on Packet Typeโ€‹

Use mangle rules to mark different traffic types, then route each to preferred ISP:

/ip firewall mangle
# VoIP traffic prefers ISP-1 (lower latency)
add chain=prerouting protocol=udp dst-port=5060,5061 \
action=mark-routing new-routing-mark=to-isp1 passthrough=yes comment="VoIPโ†’ISP-1"

# Video streaming prefers ISP-2 (higher bandwidth)
add chain=prerouting dst-port=443 \
action=mark-routing new-routing-mark=to-isp2 passthrough=yes comment="HTTPSโ†’ISP-2"

# Create separate routing tables (Method 2)
/ip route
add dst-address="0.0.0.0/0" distance="1" gateway="192.168.1.1" \
check-gateway="ping" routing-table=to-isp1 comment="ISP-1-VoIP"
add dst-address="0.0.0.0/0" distance="1" gateway="192.168.1.2" \
check-gateway="ping" routing-table=to-isp2 comment="ISP-2-Video"

4. Active-Active Load Balancing (PCC)โ€‹

Distribute traffic evenly between two ISPs using Per-Connection Classifier:

/ip firewall mangle
add chain=prerouting action=mark-routing new-routing-mark=isp1 \
per-connection-classifier=both-addresses-and-ports:2/1 passthrough=yes

add chain=prerouting action=mark-routing new-routing-mark=isp2 \
per-connection-classifier=both-addresses-and-ports:2/2 passthrough=yes

/ip route
add dst-address="0.0.0.0/0" distance="1" gateway="192.168.1.1" \
routing-table=isp1 check-gateway="ping" comment="ISP-1"
add dst-address="0.0.0.0/0" distance="1" gateway="192.168.1.2" \
routing-table=isp2 check-gateway="ping" comment="ISP-2"

Each connection goes to either ISP-1 or ISP-2 based on source/destination hash.

5. Bandwidth Management Per ISPโ€‹

Limit each ISP route to prevent one from saturating:

/ip firewall mangle
# Queue ISP-1 traffic for rate limiting
add chain=forward routing-mark=to-isp1 action=mark-packet new-packet-mark=isp1-limited passthrough=yes

/queue
add name="isp1-queue" parent=ether1 direction=in limit-at=50M target=192.168.1.1
add name="isp2-queue" parent=ether2 direction=in limit-at=50M target=192.168.1.2


โœ… Failover Configuration Complete! Your network now has redundant ISP paths with automatic failover. Monitor the routes and adjust check-gateway intervals based on your ISP stability.