Disable/Enable firewall rule based on ping result

Hi All,

Im looking to create a script to enable/disable rule if a internal server is unavailable based on ping is most likely the only option.

Could someone point me in the right direction, or tell me if its not the right way to go about this.

Regards

Michael

Here’s a base to work on:

:local alwaysRun true;

:while ($alwaysRun) do={
    
    :if ([ping address=10.155.0.255 count=5] = 0 ) do={
    
# disable the routes


} else={

# enable the routes

    }
}

Replace the IP address you want to ping and put the routes you want to enable/disable inside the script. Script will continuously run and ping 5 times - if no response, drop routes. If on next round of pings it pings, then it enables. You can add a delay at the start of the while loop to run every minute or so. If you want the script to keep working after reboot, then add it to Scheduler. More information can be found https://wiki.mikrotik.com/wiki/Manual:Scripting and https://wiki.mikrotik.com/wiki/Manual:System/Scheduler

use netwatch instead
simple and easier