Community discussions

just joined
Posts: 10
Joined: Fri Mar 14, 2014 6:35 pm

Re: Useful scripts

Fri May 24, 2019 1:10 pm

HI! I am looking for a way to get the router to act when a certain LAN client (ip address) sends a packet to a certain WAN address. The action would be a webhook. What would be the most effective way to setup something like this? Can anyone point me to the right direction, please?

Would I have to use packet sniffer and fetch?

Thank you!

I guess, one way to do this is to setup a firewall rule, which would then trigger a script similar to this ... te_Desktop

However, the script would have to run every 10 seconds... Is there another way to have the firewall rule trigger a script?
Did you ever get anywhere with this? I'm trying to figure out the same thing. When my video doorbell is pressed it sends an alert via a "cloud" service. I'm trying to trigger something local too and this would be ideal.

just joined
Posts: 2
Joined: Wed Aug 08, 2018 3:00 pm

Re: Useful scripts

Sun Aug 04, 2019 1:19 am

Share couple of my scripts here.

1. Script automatically updates router to the latest firmware.
When script finds new update it sends email notification that upgrade process has started, system backup and config file are in attachment. After firmware and routerboard got updated, it sends second email which tells that upgrade process has been finished.
You can choose update channel and even allow to update only patch versions.
Link to instruction: ... to-Updater

2. Simple script that updates your public IP in DuckDNS dynamic ip service. (Free dyndns alternative)
Link to instruction: ... IP-Updater
User avatar
Forum Guru
Forum Guru
Posts: 1239
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Useful scripts

Sun Aug 04, 2019 9:32 am

From all the problem I see that MT have after updating routers, I would not recommend to do an automatically upgrade without any possible to control it when it should run. At least on remote devices. I did lost my L2TP IPSec tunnel after upgrade due to change in config. So take care with this.
Another thing is that a backup of the router may not work across upgrade, so you may need to downgrade to restore a backup.

You could setup a web page that each router in a script fetch some data. If it get upgrade_hap_lite=ok found on the page, then It can upgrade automatically, since you then can hold the upgrade until you have tested the release in a controlled environment.

I see that you can set it to only upgrade minor version, that may help some with backup restore, but not when MT add error or big changes in minor version as it has happen many times lately. (change in wifi that made it stop depending on what you have setup)

Also you can remove the ; at end of all lines. Only needed if you have more than one command at same line.
You have even some line with ; and some without like:
:if ($osVerNewNum > $osVerCurrentNum) do={
:set isUpdateAvailable true;
:log info ("New firmware version found: $osVerNew");
} else={
:log info ("New firmware version not found.")
When you send message to the log system, I do like better that it are in a machine readable format. Since I work allot with Splunk, it reads message with out any modification if you do change from:
text some more text data
if data has spaces, use quotes
router_identity="rotuer 128"

Eks (join word, use =, remove comma, if there are spaces in data use double quotes example if board_name has space)
"Upgrading firmware on router $[/system identity get name], board name: $[/system resource get board-name],
"script=firmware_upgrade router=$[/system identity get name] board_name=\"$[/system resource get board-name]\" ........
How to use Splunk to monitor your MikroTik Router


Who is online

Users browsing this forum: Bing [Bot] and 13 guests