WAN down checking script

Hi,
i need a script that check wan connection (ping to gateway). if it is dead (Ping is unreachable) then all of my users get a message via my webserver. otherwise all of my http, goes to my proxy server.
But i don’t know how to write scripts.

situation like this:
if [ping my_gateway = unreachable] then
ip firewall nat set chain=dstnat in-interface=Public protocol=tcp dst-port=80 action=dst-nat
to-addresses=192.168.100.2 to-ports=80 comment=“” disabled=no

else
ip firewall nat set chain=dstnat in-interface=Public protocol=tcp dst-port=80 action=dst-nat
to-addresses=192.168.140.3 to-ports=8080 comment=“” disabled=no


Please Help
Thanks

This is what I came up with.

You will need to change a.b.c.d. to your gateway that you would like to monitor.

/ip firewall nat
add action=dst-nat chain=dstnat comment=“Wan Monitor” disabled=no dst-port=80 in-interface=ether3 protocol=tcp to-addresses=192.168.140.3 to-ports=8080

/tool netwatch
add comment=“” disabled=no down-script=“/ip firewall nat set [find comment="Wan Monitor"] to-addresses=192.168.100.2 to-ports=80” host=a.b.c.d interval=10s timeout=1s up-script=“/ip firewall nat set [find comment="Wan Monitor"] to-addresses=192.168.140.3 to-ports=8080”

-Louis

Hi,

Use Netwatch, just copy your up and down scripts in there. It works for me.

http://www.mikrotik.com/testdocs/ros/2.9/tools/netwatch.php