How to Configure 2 WAN Failover in Mikrotik

Failover technique is a network technique by providing two or more connection lines where when one path dies, then the connection still runs supported by another path. This failover technique is quite important when we want a reliable internet network connection.

Tutorial Failover 2 Internet Connection in Mikrotik which I will discuss this time a bit special because it is not like the usual failover. So here I will create an internet network using 2 connections, namely the main connection using Fiber Optic and backup connection with USB Modem. In general, the network topology as follows:

Configure 2 WAN Failover in Mikrotik
Configure 2 WAN Failover in Mikrotik

 

 

The failover technique I will use this time is to make a connection from Fiber Optic as the main line and when the main line is down (down) then the connection will directly move to the backup path. And if the main connection back to normal (up) then the connection will remove to the main line. This can not be done using a regular Failover technique that only uses the ping check gateway on the Route.

To apply this technique I use a mix of tools in Mikrotik, ie Script, Netwatch, and Check gateway on Route. Okay just go to Tutorial Failover 2 Internet Connection in Mikrotik. Here I will not discuss the way from the beginning, but straight to the core of its failover way.

1. Make sure both internet connection that you will use is running well in Mikrotik.

2. Go to System -> Script -> Add. Add the following 2 Mikrotik Scripts:

Failover Script:

 

Mikrotik 2 wan failover
Mikrotik 2 wan failover

 

Script back to the mainline:

 

Script back to the mainline
Script back to the mainline

 

3. Create the Netwatch rule. Go to Tools -> Netwatch -> Add. Create the following two rules:
Netwatch Failover:
[Host Tab] – Host: 8.8.8.8
– Interval: 00:00:03
– Timeout: 1000 ms
[Tab Down] On Down: failover (adjust its script name)

 

2 Wan Failover in Mikrotik
2 Wan Failover in Mikrotik

 

Netwatch Back to the main line:

[Host Tab] – Host: 8.8.8.8
– Interval: 00:00:03
– Timeout: 1000 ms
[Tab Up] On Up: back2main (customize with the name of the script)

 

4. Edit the Mikrotik routing table. Log in to IP -> Routes. Create like the following picture:

 

2 Wan Failover in Mikrotik Routes
2 Wan Failover in Mikrotik Routes

 

The route for the main line:

Manually create a route for the main path with configuration:
– Dst Address: 0.0.0.0/0
– Gateway: ether1 (select interface connected to the main line)
– Distance: 1
– Check Gateway: ping
– The most important thing is to create a comment. Click the Comment menu -> fill in: main

 

2 Wan Failover in Mikrotik Routes
2 Wan Failover in Mikrotik Routes

 

The route for the backup path:

Manually create a route for the main path with configuration:
– Dst Address: 0.0.0.0/0
– Gateway: smartfren (select the interface that is connected to the backup path)
– Distance: 2
– The most important thing is to create a comment. Click Comment menu -> fill: backup

The route for ping netwatch:
Create a route for the Netwatch ping path with configuration:
– Dst Address: 0.0.0.0/0
– Gateway: ether1 (select interface connected to the main line)
– Distance: 1

5. The configuration is complete. Now check that the configuration is working properly. How to do ping google, and try to turn off the main line connection. If the configuration is correct, then ping will time out for a while then reply again which indicates if failover works. Turn on the main line connection again, so if the configuration is correct, the connection will move directly back to the main line.