fbpx

With MikroTik's netwatch tool I can simulate a failover (activate route 1 and deactivate route 0). How do I ensure that when route 0 has access to the Internet, route 1 is deactivated and route 0 is activated, in the case that it has 2? wan?

This can be done through scripts, in the case of a guide on how to do it you can see the following link https://wiki.mikrotik.com/wiki/Manual:Tools/Netwatch

To configure an automatic failover using the Netwatch tool in MikroTik RouterOS, you can manage two WAN connections so that when the main connection (WAN 1) is available, that one is used, and in case of failure, the backup connection is automatically activated ( WAN 2).

Here's how you can achieve this by properly configuring Netwatch and routing rules.

Step 1: Netwatch Configuration

Netwatch is a tool in MikroTik RouterOS that allows you to monitor the availability of specific hosts on the network and run scripts based on state changes.

  1. Access MikroTik RouterOS: You can do this through WinBox, WebFig, or SSH.
  2. Navigate to Netwatch: go to Tools > Netwatch.
  3. Configure Netwatch for WAN 1:
    • Host: Set an IP address that is a good indicator of Internet availability, such as a public DNS server or a trusted IP address.
    • Interval: Defines how often the host availability should be checked.
    • timeout: Sets the wait time for the ping response.
    • Up Script: This script will be executed when the host is reachable. It can be used to enable WAN 1 route and disable WAN 2 route. Example:

      /ip route set [find comment="WAN1"] disabled=no
      /ip route set [find comment="WAN2"] disabled=yes
    • DownScript: This script will be executed when the host is unresponsive. Use it to disable WAN 1 route and enable WAN 2 route. Example:

      /ip route set [find comment="WAN1"] disabled=yes
      /ip route set [find comment="WAN2"] disabled=no

Step 2: Route Configuration

You need to configure static routes for both WAN connections in MikroTik.

  1. Configure Static Routes:
    • Go to IP > Routes.
    • Create two routes, one for each WAN. Be sure to set a description or comment that allows you to easily identify each one (for example, “WAN1” and “WAN2”).
    • Normally, both routes would have the destination 0.0.0.0/0 (default route), but you must disable one of the two, based on your Netwatch script.

Step 3: Verification and Testing

Once configured, perform tests to ensure that failover works correctly:

  • Physically disconnect WAN 1 and check if traffic starts going through WAN 2 automatically.
  • Review Netwatch logs and results to ensure scripts run as expected.

Additional considerations

  • Security and Reliability: Make sure that the scripts and IPs used for testing are secure and reliable to avoid false positives or negatives in detecting network availability.
  • Operational: Adjusts the intervals and wait times according to the sensitivity and desired performance for the failover.

Setting up failover with Netwatch is an efficient and relatively simple way to improve the redundancy and availability of your Internet connection using MikroTik RouterOS.

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