Tuesday, September 22, 2020

Mikrotik Script Example

Mikrotk script, that we can use to simplify our administering task. At mikrotik, it is possible automatic command execution using script. Such as, send an email or sms to administrator for any critical situation, automatically enable or disable route for any unexpected situation and many more.

In this tutorial, we will discuss about some script that we can use at various situation.


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