fbpx

Demystifying Netwatch: Optimizing Network Management with MikroTik RouterOS

Facebook
Twitter
LinkedIn
WhatsApp
Telegram

MikroTik RouterOS stands out for its rich range of tools that allow network administrators to have precise control over their infrastructures. Among these tools, Netwatch emerges as an essential resource to monitor and automate actions on the network.

At the end of the article you will find a small test that will allow you assess the knowledge acquired in this reading

Basic Netwatch Configuration

Before we dive into specific examples, it is essential to understand the basic configuration of Netwatch. The basic syntax involves creating a Netwatch rule, specifying the IP address or domain name of the resource to monitor and the script to be executed when the set conditions are met.

/tool ​​netwatch add host= interval= timeout= \

    up-script= down-script= comment=
  • host: The IP address or domain name of the resource to monitor.
  • interval: The time interval between checks.
  • timeout: The time limit to consider that the resource is not available.
  • up-script: The script to run when the resource becomes accessible.
  • down-script: The script to run when the resource becomes inaccessible.
  • comment: An optional comment to describe the rule.

Important: These properties are available in RouterOS v6 up to RouterOS 7.3.1

Starting with RouterOS v7.4, Netwatch functionality has been expanded; previous versions only supported simple ICMP options. While, when upgrading to the new version, the old Netwatch entries will remain unchanged, reporting the option type “simple”, retaining the same functionality. Monitoring can be carried out based on the following types:

  • ICMP - Pings a specific IP address - hosts, with an option to adjust threshold values
  • Simple: use ping, without using advanced metrics
  • TCP conn: to test the TCP connection
  • HTTP GET/HTTPS GET: request against a server you are monitoring
Demystifying Netwatch: Optimizing Network Management with MikroTik RouterOS

Practical Examples of Using Netwatch

1. Automatic Interface Restart

Suppose we want to automatically restart a router interface when we detect that the connection to a specific server is down. We can achieve this by configuring Netwatch to monitor connectivity to the server and run a script that restarts the interface if the connection is lost.

/tool ​​netwatch add host=my_server.com interval=10s timeout=5s \

    down-script="/interface ethernet restart ether1" comment="Restart ether1 if connection fails"

2. Connection Loss Notification

Instead of performing automatic actions, we can configure Netwatch to send a notification when connection to a critical resource is lost. In this example, we will send an email when a web server is unavailable.

/tool ​​netwatch add host=my_web_server.com interval=30s timeout=10s \

    down-script="/tool ​​e-mail send [email protected] subject=Alert! Web Server Not Available body=The web server is not responding." \

    comment="Notify loss of connection to the web server"

3. Automatic Response to Ping Loss

Netwatch can also be used to automatically respond to a device's loss of connectivity by running custom scripts. Below is an example of changing the configuration of a firewall rule when connectivity to a device is lost.

/tool ​​netwatch add host=critical_device interval=20s timeout=8s \

    down-script="/ip firewall filter set [find comment='Allow_Critical_Device'] disabled=yes" \

    up-script="/ip firewall filter set [find comment='Allow_Critical_Device'] disabled=no" \

    comment="Change firewall settings when connectivity is lost"

Conclusions and Final Considerations

Netwatch on MikroTik RouterOS is a powerful tool that provides network administrators with the ability to automatically monitor and respond to changes in the state of network resources.

The flexibility to run custom scripts in response to specific events provides granular control over the network infrastructure.

By strategically deploying Netwatch, administrators can improve the availability, efficiency, and responsiveness of their networks, reducing downtime and improving the user experience.

Understanding basic configuration and applying practical examples allows network professionals to make the most of this versatile tool in MikroTik RouterOS.

Brief knowledge quiz

What do you think of this article?
Do you dare to evaluate your learned knowledge?

QUIZ - Demystifying Netwatch: Optimizing Network Management with MikroTik RouterOS

Recommended book for this article

Do you want to suggest a topic?

Every week we post new content. Do you want us to talk about something specific?
Topic for the next blog

Leave a comment

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

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