Home / Mikrotik Router Configuration / Configure 2 WAN Failover in Mikrotik

Configure 2 WAN Failover in Mikrotik

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:

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:

: If ([/ ip route get [/ ip route find comment = “main”] disabled] = yes) do = {/ ip route enable [/ ip route find comment = “main”]} else = {/ ip route disable [/ Ip route find comment = “main”]}

2 Wan Failover in Mikrotik

Script back to the main line:

: If ([/ ip route get [/ ip route find comment = “main”] disabled] = yes) do = {/ ip route enable [/ ip route find comment = “main”]}

2 Wan Failover in Mikrotik

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

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)

2 Wan Failover in Mikrotik

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

2 Wan Failover in Mikrotik

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

The route for 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. 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.
[\hide]

About admin

Check Also

Load Balance 2 WAN in Mikrotik

How to Load Balance 2 WAN in Mikrotik

How to Load Balance 2 WAN in Mikrotik This article again discusses Load Balancing, which …

11 comments

  1. It works very well for me

  2. This is actually helpful, thanks.

  3. Thanks, it’s very informative

  4. Thanks, it is very informative

  5. It works very well for me

  6. Thanks to the great manual

  7. I enjoy the article

  8. Thanks, it is quite informative

  9. Thanks for the great guide

  10. I like the report

  11. This is really useful, thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *