I can verify this works on a MT RouterBOARD wAP R-2nD with RouterOS v6.43.7
I only commented out the first logging and changed action to “/system reboot”. I scheduled for every two minutes
I encountered the same problem and just checked the “Don’t Require Permissions” checkbox on the script setup screen. Now I don’t know if that’s considered safe from a router security standpoint, but it eliminated the problem.
Updated version(s) of my WatchDog auto-reboot scripts I am now using.
FYI - Back when I first posted my script to auto reboot a Mikrotik when the network lost connectivity , it used to work. Since then (years ago and several ROS versions ago) my scripts ran great - but newer versions of ROS have changed some permissions needed for scripts to perform what my scripts were trying to do. The good news is I have changed and modified my scripts and for me , they now function better.
Below are some instructions and the scripts to configure your Mikrotik to use my WatchDog auto-reboot scripts.
1st - On your core router facing the Internet , create a loopback interface (or a bridge or any interface) that has an ip address of 192.0.2.254 / 32
Note , 192.0.2.254 is a safe IP address to use because it is not on the Internet and the entire 192.0.2.0/24 network is intended to be used for in-house lab testing networks. After you have a 192.0.2.254/32 IP address on your network, every device in your network should be able to ping 192.0.2.254
2nd - Create three scripts on all of your other Mikrotik routers using the following:
:if ([/ping $addresstoping interval=1 count=1] =0) do={
:log error "NetWatchVersion2-Reboot-NotConnected - ----->ping to $addresstoping failed on attempt $counter of $maxcounter -- Will try again in $sleepseconds seconds"
} else {
:log warning "NetWatchVersion2-Reboot-NotConnected - -----> ping success on to $addresstoping attempt $counter of $maxcounter <----- No Further testing needed --- Program will exit -----"
exit
quit
end
:set continue false
:set goodpings ($goodpings +1)
}
:if ($counter=$maxcounter) do={:set continue false;}
}
:log error "NetWatchVersion2-Reboot-NotConnected - --- executing reboot script in to seconds"
:delay 10
/system script run RebootScript
:delay 10
:log error "NetWatchVersion2-Reboot-NotConnected - --- I should of rebooted by now - will retry a reboot script againt in to seconds"
:delay 10
/system script run RebootScript
:delay 10
exit
quit
end
These scripts and netwatch settings now do the following when a Mikrotik can NOT ping 192.0.2.254
One netwatch will perform a site-survey and store the results as a file. Using winbox, you can drag the files it creates "SiteSurvey-wlan1-20seconds--txt.rtf" and "SiteSurvey-wlan1-90seconds--txt.rtf" to your windows desktop and double-click on it to open it and see the results of a remote site-survey.
One netwatch will perform a reboot if the Mikrotik remains unable to ping 192.0.2.254 after a few minutes.
The reboot function has a long enough period prior to a reboot to allow a remote wireless client Mikrotik to perform a site-survey possibly reconnect.
The scripts will abort if/when 192.0.2.254 starts to answer pings prior to a reboot
If you wish to test this , try this testing procedure:
configure your core router to answer a ping to 192.0.2.254
place the above scripts and netwatch code on a test Mikrotik
FYI - Use these scripts at your own risk and assume I may errors in my code
FYI - If you wish to auto reboot all of your mikrotiks and also have your remote Mikrotiks all perform site-surveys (in my case , hundreds to thousands of customer wireless client Mikrotiks) , simple disable 192.0.2.254 on your core router for about 10 minutes.
Please post any results or your ideas on how to improve these WatchDog auto-site-survey auto-reboot scripts.
What i would like to do is add a script for when a route becomes unreachable that the Mikrotik reboots.
What i would like to achieve is im having issues with stale voice connections and my PABX requires a reboot before they work again has anyone solved this or have an idea what to do ?