fbpx

Can 2 providers be connected to the same MikroTik device and if one stops having internet, can it connect to the other?

Yes we can do it through static routes. Having two static exit routes to the Internet for each of the providers and using the distance option on the route. The main provider should be given a low distance and the secondary provider a high distance. The route with the lowest distance is the one that will remain active. The distance is a number that can be within the range 1 to 255.

It is possible to connect two Internet providers to the same MikroTik device and configure it so that, if one stops having an Internet connection, the traffic is automatically redirected to the other provider. This configuration is known as WAN failover or load balancing with failover. Although load balancing distributes traffic between two or more connections, failover ensures that if one connection fails, traffic is automatically redirected to another active connection.

Here we explain how to configure WAN failover in MikroTik RouterOS:

Step 1: Configure WAN Interfaces

First, you need to configure both WAN interfaces with the IP addresses provided by your ISPs. This is usually done in IP > Addresses.

Step 2: Configure the Default Gateway

Next, configure the default gateway for each of the Internet providers in IP > Routes. You must add a route for each provider:

  • For the primary ISP, add a route with the gateway provided by the ISP and leave it with a distance of 1.
  • For the backup ISP, add a route with the gateway provided by this ISP and set a longer distance, for example, 2.

Step 3: Configure Failover

Failover can be configured using the verification script and recursive routes. You'll need to create a script that verifies the Internet connection, for example by pinging a trusted public IP address (such as Google DNS 8.8.8.8). If the ping fails, the script can change the distance of the routes to cause the traffic to be redirected to the other ISP.

Step 4: Create a Verification Script

Create a script in System > Scripts verify connectivity and adjust route distances as necessary. Here's a basic example of what the script might look like:

:if ([/ping 8.8.8.8 count=3] = 0) do={
    /ip route set [find comment="ISP1"] distance=2
    /ip route set [find comment="ISP2"] distance=1
} else={
    /ip route set [find comment="ISP1"] distance=1
    /ip route set [find comment="ISP2"] distance=2
}

This script tries to ping 8.8.8.8 three times. If it fails (indicating that the primary ISP is down), it changes the distance of the routes to prioritize the backup ISP.

Step 5: Schedule the Script

Finally, schedule the script to run periodically on System > Scheduler. This will ensure that the script runs at regular intervals, allowing for automatic detection and failover.

Additional considerations

  • Testing: After configuring failover, test by physically disconnecting one of your ISPs to ensure that failover is working as expected.
  • Load balancing: If you want to use both ISPs at the same time, you can consider setting up load balancing in addition to failover. However, load balancing requires additional configurations.
  • Structural: Keep track and monitor connections so you can react quickly to any problems.

This basic failover setup should provide you with automatic switching between two Internet providers in case one fails, improving the reliability of your Internet connection.

There are no tags for this post.
Did this content help you?
Facebook
Twitter
LinkedIn
WhatsApp
Telegram

Other documents in this category

Leave your comment

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

Tutorials available at MikroLABs

No Courses Found!

DISCOUNT CODE

AN24-LIB

applies to MikroTik books and book packs

Days
Hours
Minutes
Seconds

Introduction to
OSPF - BGP - MPLS

Sign up for this Free course

MAE-RAV-ROS-240118
Days
Hours
Minutes
Seconds

Sign up for this Free course

MAS-ROS-240111

Promo for Three Kings Day!

KINGS24

15%

all the products

MikroTik courses
Academy courses
MikroTik books

Take advantage of the Three Kings Day discount code!

* promotion valid until Sunday January 7, 2024
** the code (KINGS24) applies to shopping cart
*** buy your course now and take it until March 31, 2024

New Year's Eve Promo!

NY24

20%

all the products

MikroTik courses
Academy courses
MikroTik books

Take advantage of the New Year's Eve discount code!

* promotion valid until Monday, January 1, 2024
** the code (NY24) applies to shopping cart
*** buy your course now and take it until March 31, 2024

Christmas discounts!

XMAS23

30%

all the products

MikroTik courses
Academy courses
MikroTik books

Take advantage of the discount code for Christmas!!!

**codes are applied in the shopping cart
Promo valid until Monday December 25, 2023

CYBER WEEK DISCOUNTS

CW23-MK

17%

all MikroTik OnLine courses

CW23-AX

30%

all Academy courses

CW23-LIB

25%

all MikroTik Books and Book Packs

Take advantage of the discount codes for Cyber ​​Week!!!

**codes are applied in the shopping cart
Promo valid until Sunday December 3, 2023

BLACK FRIDAY DISCOUNTS

BF23-MX

22%

all MikroTik OnLine courses

BF23-AX

35%

all Academy courses

BF23-LIB

30%

all MikroTik Books and Book Packs

Take advantage of the discount codes for Black Friday!!!

**Codes are applied in the shopping cart

codes are applied in the shopping cart
valid until Sunday November 26, 2023

Days
Hours
Minutes
Seconds

Sign up for this Free course

MAE-VPN-SET-231115

Halloween promo

Take advantage of discount codes for Halloween.

Codes are applied in the shopping cart

HW23-MK

11% discount on all MikroTik OnLine courses

11%

HW23-AX

30% discount on all Academy courses

30%

HW23-LIB

25% discount on all MikroTik Books and Book Packs

25%

Register and participate in the free course Introduction to Advanced Routing with MikroTik (MAE-RAV-ROS)

Today (Wednesday) October 11, 2023
7pm to 11pm (Colombia, Ecuador, Peru)

MAE-RAV-ROS-231011