done? There are two scripts. The script "gw_2" is executed once when status of host changes to up.
In our case, it's equivalent to entering this console command:
[admin@MikroTik] > /ip route set [/ip route find dst 0.0.0.0] gateway 10.0.0.217
The /ip route find dst 0.0.0.0 command returns list of all routes whose dst-address value is
0.0.0.0. Usually, that is the default route. It is substituted as first argument to /ip route set
command, which changes gateway of this route to 10.0.0.217
The script "gw_1" is executed once when status of host becomes down. It does the following:
[admin@MikroTik] > /ip route set [/ip route find dst 0.0.0.0] gateway 10.0.0.1
It changes the default gateway if 10.0.0.217 address has become unreachable.
Here is another example, that sends e-mail notification whenever the 10.0.0.215 host goes down:
[admin@MikroTik] system script> add name=e-down source={/tool e-mail send
{... from="[email protected]" server="159.148.147.198" body="Router down"
{... subject="Router at second floor is down" to="[email protected]"}
[admin@MikroTik] system script> add name=e-up source={/tool e-mail send
{... from="[email protected]" server="159.148.147.198" body="Router up"
{.. subject="Router at second floor is up" to="[email protected]"}
[admin@MikroTik] system script>
[admin@MikroTik] system script> /tool netwatch
[admin@MikroTik] system netwatch> add host=10.0.0.215 timeout=999ms \
\... interval=20s up-script=e-up down-script=e-down
[admin@MikroTik] tool netwatch> print detail
Flags: X - disabled
0
host=10.0.0.215 timeout=998ms interval=20s since=feb/27/2003 14:15:36
status=up up-script=e-up down-script=e-down
[admin@MikroTik] tool netwatch>
Page 626 of 695
Copyright 1999-2007, MikroTik. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.
Other trademarks and registred trademarks mentioned herein are properties of their respective owners.