Basically the script does a round of pings to 3 set addresses, they can be any addresses that you want them to be. If enough of them fail, it then checks to see if it has already failed by seeing if a route has been disabled. If it has not been disabled then it goes through the actions in the first if clause. If it has already been disabled, then it skips and waits to run again. This script relies upon 3 routes per out interface, the one for PCC, one for the main routing table, and one for it to test. The test route will always be online, so it can try sending pings out of that routing table. On a successful ping test, it does the else clause, first it sees if route has been disabled, if so, then it knows that it has just recovered from a down ISP, so it preforms the actions in that clause, if the route is enabled, then it knows it’s just another successful test and does nothing.
You can obviously add in extra actions or modify it to fit your needs, such as disabling or enabling other firewall rules, routes, etc.
:local x 0; {:do {:set x ($x + 1)} while (($x < 3) && ([/ping 4.2.2.1 interval=1 routing-table=ISP1_Test count=3]<=1))};
:local y 0; {:do {:set y ($y + 1)} while (($y < 3) && ([/ping 4.2.2.2 interval=1 routing-table=ISP1_Test count=3]<=1))};
:local z 0; {:do {:set z ($z + 1)} while (($z < 3) && ([/ping 4.2.2.3 interval=1 routing-table=ISP1_Test count=3]<=1))};
:if ($x=3 && $y=3 && $z=3) do={:if ([/ip route get [find comment="ISP1-Script"] disabled]=no) do={:log error "ISP1 Down";
/ip route disable [find comment=ISP1];
/ip route disable [find comment=ISP1-Script];
/tool e-mail send to="support@e-mail.com" subject=([/system identity get name] ." ISP1 Down") body=("On ".[/system clock get date]." at ".[/system clock get time]." ISP1 appears to have gone offline.");
delay delay-time=5;
:foreach i in=[/ip firewall connection find connection-mark=outside1_connection] do= {ip firewall connection remove $i;}
}
} else { :if ([/ip route get [find comment="ISP1-Script"] disabled]=yes) do {:log info "ISP1 UP";
/ip route enable [find comment=ISP1];
/ip route enable [find comment=ISP1-Script];
/tool e-mail send to="support@e-mail" subject=([/system identity get name] ." ISP1 UP") body=("On ".[/system clock get date]." at ".[/system clock get time]." ISP1 appears to have come back online.");
}
}
Here’s the script-less way, it’s mentioned about 1/2 down. I haven’t ever tried it out, so I personally don’t know how well it works.
http://forum.mikrotik.com/t/best-method-to-load-balance-2-internet-line/37337/1