Having lots of ISP reliability problems. When WAN goes down, users have great wifi connections but no internet due to ISP going down. Is there a way to detect the WAN connection going down and back up? Ideally some notification would be sent, but I would settle for log entries.
Start with this one:
.
/tool netwatch
add down-script="do {ip firewall layer7-protocol add name=NetWatchTimeSince comment=[/system resource get uptime] } on-error={};\r\
\n/local NetWatchDuration ([/system resource get uptime] - [/ip firewall layer7-protocol get [find name=NetWatchTimeSince] comment])\r\
\n/log warning (\"Netwatch: DOWN | check 1.1.1.1 | OnLine Duration was: \".\$NetWatchDuration) \r\
\n/ip firewall layer7-protocol set [find name=NetWatchTimeSince] comment=[/system resource get uptime];\r\
\n#/system script run lteatreset\r\
\n\r\
\n" host=1.1.1.1 interval=10s timeout=500ms up-script="do {ip firewall layer7-protocol add name=NetWatchTimeSince comment=[/system resource get uptime] } on-error={};\r\
\n/local NetWatchDuration ([/system resource get uptime] - [/ip firewall layer7-protocol get [find name=NetWatchTimeSince] comment])\r\
\n/log warning (\"Netwatch: UP | check 1.1.1.1 | OffLine Duration was: \".\$NetWatchDuration) \r\
\n/ip firewall layer7-protocol set [find name=NetWatchTimeSince] comment=[/system resource get uptime];\r\
\n"
.
WinBox > Tools > Netwatch
Results:

Thanks for the example. Using it, and examples from the Manual, I came up with something that seems it should work but has a problem. Following the example in the manual I created two simple scripts; ISPup and ISPdown. The ISPdown script is: /log warning “ISP down”, ISPup is: /Log warning “ISP up”. I then used up-script=ISPup and down-script=ISPdown to set up the netwatch for my ISP gateway IP address. Generating a network state change by unplugging and re-plugging the cable to the router (after the specified interval) did not create any log entries. However, if I replace the name of the scripts with the contents of the scripts (e.g. /log warning “ISP up” instead of the script name ISPup in the up-script field) I get log entries during my test. Any idea why ISPup and ISPdown scripts don’t seem to run?
Using the naked name of a script instead of “/script run ” works in some places in RouterOS, not in others. Try “/script run ” instead if you need to run an actual multi-line script.
TomSF
Two problems
- You should use: /system script run “Name of script to run”
- NetWatch use a own user *sys and if he try use a remote script then those script’s must have additional permision: /system script set dont-require-permissions=yes “Name of script to run”
/system script set dont-require-permissions=yes was the explanation. Thanks.