Part 1: WAN Failover for High Availability

How to Configure MikroTik WAN Failover for High Availability: Complete Guide for Network Engineers

Network downtime can be costly for businesses. To ensure continuous connectivity, MikroTik routers can be configured with WAN failover. This allows traffic to switch automatically to a backup ISP when the primary link fails, providing high availability.

🌐 What is WAN Failover?

WAN failover is a redundancy feature where multiple internet connections are configured. If the primary WAN connection goes down, traffic is automatically routed through the secondary connection, ensuring uninterrupted service.

⚙️ Basic Network Setup

  • WAN1: Primary ISP (e.g., ether1)
  • WAN2: Secondary ISP (e.g., ether2)
  • LAN: Internal network (e.g., ether3+)

🛠 Step 1: Configure IP Addresses

/ip address
add address=192.168.1.2/24 interface=ether1 comment="WAN1"
add address=192.168.2.2/24 interface=ether2 comment="WAN2"
add address=192.168.88.1/24 interface=bridge comment="LAN"

🛠 Step 2: Set Default Routes with Distance

Assign lower distance to WAN1 (primary) and higher distance to WAN2 (backup).

/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2

🛠 Step 3: Add Firewall NAT Rules

/ip firewall nat
add chain=srcnat out-interface=ether1 action=masquerade
add chain=srcnat out-interface=ether2 action=masquerade

🛠 Step 4: Configure Netwatch (Optional for Scripted Failover)

You can use Netwatch to monitor WAN1 and automatically enable WAN2 when WAN1 fails.

/tool netwatch
add host=8.8.8.8 interval=10s timeout=2s \
down-script="/ip route disable [find gateway=192.168.1.1]" \
up-script="/ip route enable [find gateway=192.168.1.1]"

✅ Testing the Failover

  1. Disconnect WAN1 and check if traffic switches to WAN2.
  2. Reconnect WAN1 and verify that it resumes as the primary route.

🔒 Best Practices

  • Always use check-gateway=ping for reliable failover.
  • Monitor critical gateways like 8.8.8.8 or your ISP DNS.
  • Use scripting or Netwatch for faster failover response.
  • Log events to track failover status.

Conclusion

By configuring WAN failover on MikroTik, you can ensure high availability and minimize downtime for your network. Whether you use static routes with distances or automate with Netwatch, your business will benefit from reliable internet redundancy.

Post a Comment

Previous Post Next Post