Improved Netwatch II
Here is how I implemented this code. In Winbox go to tools then netwatch. Click on the + sign and add an ip address ( I used a dns server that is located outside our network for extra reliability ) then I changed the timeout setting to 100ms and also changed the interval to 5ms. The first script below (at bottom of page)is used to failover to your backup and the 2nd script will make it fail back over if your ping times go high or if it can't get to the ip address you have entered. I'm not sure if it makes a difference but I set up 2 different dns's ( 1 dns for each script). Don't forget that you must set a comment on the interface to match the find comment= line like it is below and I put the same comment on the interface page and on the routes page to.
[admin@wnoi3] interface> print Flags: X - disabled, D - dynamic, R - running
# NAME TYPE RX-RATE TX-RATE MTU
0 R ;;; Default Route
ether1 ether 0 0 1500
1 R ;;; ap 1
ether2 ether 0 0 1500
2 R ;;; ap2
ether3 ether 0 0 1500
3 R ether4 ether 0 0 1500
4 R ether5 ether 0 0 1500
5 R ether6 ether 0 0 1500
6 R ;;; Shop tower
ether7 ether 0 0 1500
7 R ;;; Back Up Route
ether8 ether 0 0 1500
8 R ether9 ether 0 0 1500
[admin@wnoi3] interface>
[admin@wnoi3] tool netwatch> print
Flags: X - disabled
# HOST TIMEOUT INTERVAL STATUS
0 ;;; switch back to dsl
12.127.16.67 100ms 5s up
1 ;;; switch to 4.5mb backbone
12.127.17.71 100ms 5s up
[admin@wnoi3] tool netwatch>
script 1:
- local i 0; :if ( [/ip route get [find comment="Default Route"] disabled]=false) do={:log info "Main Gateway down"; /ip route set [find comment="Default Route"] disabled=yes}
script 2:
- local i 0; :if ( [/ip route get [find comment="Default Route"] disabled]=true) do={:log info "Main Gateway up"; /ip route set [find comment="Default Route"] disabled=no}
Feel free to improve. Illini Wireless