Tuesday, September 22, 2020

Mikrotik Router Netwatch Script

Netwatch tool, that monitors the status of a network or a link. At a certain point in time, this tool perform ping to a predefined network or a link. If for some reason this tool does not receive ping response from that link or network, it sends a notification in the form of email or SMS to the system admin or user. Or may be re-route the traffic to a different network.

Whenever there is a change in the status of the link, related action will be taken. Netwatch tool perform this task with the help of some scripts. Whenever there is a change in the status of the link, the script related to that status will be started.

In this tutorial, we will discuss about some script that can be used into the netwatch tool.


The script for send message:-

tool sms send message="link down" phone-number=your_mobile_number channel=your_channel_number port=Your_port

For example:-

tool sms send message="link down" phone-number=123456 channel=3 port=usb3


The script for send email:-

tool e-mail send from="your_Email_Address" server=Your_imap_server user=your_user password=your_password subject="your_notification_message" to="recepient_address"

For example:-

tool e-mail send from="script@gmail.com" server=imap.gmail.com user=user_name password=your_password subject="link down" to="12345678"


The script for specific route enable:-

ip route enable [find gateway="1.1.1.1"]

or

ip route enable [find comment=”write_your_comment”]

for example:- ip route enable [find comment=”backup route”]

or

ip route enable [/ip route find comment="my comment"]

for example:- ip route enable [/ip route find comment="backup route"]


We can use any value for “find” parameter. Such as:

ip route enable [find distance=”1”]

ip route enable [find routing-mark=”backup_route”]

ip route enable [find dst-address=”2.2.2.2”]


In the same way, the script for route disable:-


ip route disable [find gateway="1.1.1.1"]

or

ip route disable [find comment=”write_your_comment”]

for example:- ip route disable [find comment=”backup route”]

or

ip route disable [/ip route find comment="my comment"]

for example:- ip route disable [/ip route find comment="backup route"]


Again, we can use any value for “find” parameter. Such as:

ip route disable [find distance=”1”]

ip route disable [find routing-mark=”backup_route”]

ip route disable [find dst-address=”2.2.2.2”]


No comments:

Post a Comment