MikroTik Internet Failover Like a Pro β‘π

Even the best internet connection has its bad days. But what if your router could automatically switch to a backup line when the main one goes down β and just as smoothly, switch back again when things recover?
Spoiler: It can.
In this post, weβre giving our MikroTik router a failover setup using WinBox, so itβll automatically use a backup interface when the primary connection drops.
Letβs go.
π§ The Goal
Weβll configure:
ether5
(via abackup-bridge
) as a backup WAN- Primary internet via
vlan100-internet
- Both inside the
internet
VRF - Automatic failover between the two
π§ Part 1: Set Up the Backup Bridge & VRF
1. Create a Bridge for Ether5
- Go to Bridge
- Click the β button
- Name it:
backup-bridge
- Click OK
2. Add Ether5 to the Bridge
- Stay in Bridge β Ports
- Click β
- Select
backup-bridge
as the bridge - Select
ether5
as the interface - Click OK
3. Add the Backup Bridge to the Internet VRF
- Go to IP β VRF
- Edit the
internet
VRF - In the Interfaces field, make sure to include:
vlan100-internet
lan-bridge
backup-bridge
β
- Click OK
β Double-check that all three interfaces show up in the internet VRF table.
4. Add a DHCP Client for the Backup Bridge
- Go to IP β DHCP Client
- Click β
- Interface:
backup-bridge
- Add Default Route β set to no (important!)
- Comment:
Backup Internet DHCP
- Click OK
Repeat for the primary interface (vlan100-internet
) if needed β make sure Add Default Route is also set to no there.
π‘ Part 2: Routing + NAT + Failover Logic
1. Create a WAN Interface List
- Go to Interface β Interface List
- Under the Lists tab, click β β Name it
WAN
- Under List Members, add:
vlan100-internet
backup-bridge
2. Update NAT Rule to Use Interface List
- Go to IP β Firewall β NAT
- Edit the existing
masquerade
rule - Change Out. Interface β to Out. Interface List
- Select
WAN
- Click OK
3. Set Static Default Routes with Gateway Check
- Go to IP β Routes
- Remove any default routes added by DHCP
Add Primary Route
- Dst. Address:
0.0.0.0/0
- Gateway: IP of your main ISP’s gateway (check DHCP lease)
- Distance:
10
- Check Gateway:
ping
- Routing Table:
internet
- Comment:
Primary Internet Route
Add Backup Route
- Dst. Address:
0.0.0.0/0
- Gateway: IP of your backup ISP (from DHCP lease)
- Distance:
20
- Check Gateway:
ping
- Routing Table:
internet
- Comment:
Backup Internet Route
π Use
IP β DHCP Client
to find the Gateway IPs for each interface.
π§ Part 3 (Optional): Auto-Update Routes with a Script
If your ISP frequently changes gateway IPs, use a script:
1. Create the Script
Go to System β Scripts β Add
Name: update-wan-routes
Enable full permissions
Paste this script:
rscKopiΓ«ren:local primaryGw "";
:local backupGw "";
:delay 2s;
:set primaryGw [/ip dhcp-client get [find interface=vlan100-internet] gateway];
:set backupGw [/ip dhcp-client get [find interface=backup-bridge] gateway];
:local primaryRouteId [/ip route find comment="Primary Internet Route" vrf=internet];
:local backupRouteId [/ip route find comment="Backup Internet Route" vrf=internet];
if ([:typeof $primaryGw] = "string" && $primaryGw != "") do={
if ($primaryRouteId = "") do={
/ip route add dst-address=0.0.0.0/0 gateway=$primaryGw distance=10 routing-table=internet comment="Primary Internet Route" check-gateway=ping vrf=internet
} else={
/ip route set $primaryRouteId gateway=$primaryGw;
}
}
if ([:typeof $backupGw] = "string" && $backupGw != "") do={
if ($backupRouteId = "") do={
/ip route add dst-address=0.0.0.0/0 gateway=$backupGw distance=20 routing-table=internet comment="Backup Internet Route" check-gateway=ping vrf=internet
} else={
/ip route set $backupRouteId gateway=$backupGw;
}
}
Click OK
2. Schedule the Script
Go to System β Scheduler β Add
- Name:
run-update-wan-routes
- Start Time:
00:00:00
- Interval:
1m
(or 5m if preferred) - On Event:
/system script run update-wan-routes
- Enable same policies as the script
- Click OK
β Testing the Failover
- Go to IP β Routes
- You should see:
- Primary route active (A flag)
- Backup route inactive (D flag)
- You should see:
- Unplug the cable from your primary WAN (e.g., ether1)
- Wait 10β30 seconds
- The primary route should go unreachable (X flag)
- The backup route becomes active (A flag)
- Try browsing the internet β it should work via the backup!
- Plug back the cable β wait β the system should switch back automatically.
π You Did It!
You now have a MikroTik router with intelligent failover. Whether your fiber link dies or your ISP has a hiccup, your network stays online β no more panic.
Coming up: load balancing between multiple ISPs, or advanced firewall tricks for WAN-specific traffic. π
Let me know if you want this as a Markdown file, export for Notion/blog, or even with screenshots!