05.01.2015 Views

MikroTik RouterOS™ v2.9

MikroTik RouterOS™ v2.9

MikroTik RouterOS™ v2.9

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

done There are two scripts. The script "gw_2" is executed once when status of host changes to up.<br />

In our case, it's equivalent to entering this console command:<br />

[admin@<strong>MikroTik</strong>] > /ip route set [/ip route find dst 0.0.0.0] gateway 10.0.0.217<br />

The /ip route find dst 0.0.0.0 command returns list of all routes whose dst-address value is<br />

0.0.0.0. Usually, that is the default route. It is substituted as first argument to /ip route set<br />

command, which changes gateway of this route to 10.0.0.217<br />

The script "gw_1" is executed once when status of host becomes down. It does the following:<br />

[admin@<strong>MikroTik</strong>] > /ip route set [/ip route find dst 0.0.0.0] gateway 10.0.0.1<br />

It changes the default gateway if 10.0.0.217 address has become unreachable.<br />

Here is another example, that sends e-mail notification whenever the 10.0.0.215 host goes down:<br />

[admin@<strong>MikroTik</strong>] system script> add name=e-down source={/tool e-mail send<br />

{... from="rieks@mt.lv" server="159.148.147.198" body="Router down"<br />

{... subject="Router at second floor is down" to="rieks@latnet.lv"}<br />

[admin@<strong>MikroTik</strong>] system script> add name=e-up source={/tool e-mail send<br />

{... from="rieks@mt.lv" server="159.148.147.198" body="Router up"<br />

{.. subject="Router at second floor is up" to="rieks@latnet.lv"}<br />

[admin@<strong>MikroTik</strong>] system script><br />

[admin@<strong>MikroTik</strong>] system script> /tool netwatch<br />

[admin@<strong>MikroTik</strong>] system netwatch> add host=10.0.0.215 timeout=999ms \<br />

\... interval=20s up-script=e-up down-script=e-down<br />

[admin@<strong>MikroTik</strong>] tool netwatch> print detail<br />

Flags: X - disabled<br />

0 host=10.0.0.215 timeout=998ms interval=20s since=feb/27/2003 14:15:36<br />

status=up up-script=e-up down-script=e-down<br />

[admin@<strong>MikroTik</strong>] tool netwatch><br />

Page 546 of 615<br />

Copyright 1999-2005, <strong>MikroTik</strong>. All rights reserved. Mikrotik, RouterOS and RouterBOARD are trademarks of Mikrotikls SIA.<br />

Other trademarks and registred trademarks mentioned herein are properties of their respective owners.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!