I have been trying some time to get some form of failover between isps to work. I have tried all the different scripts on the mikrotik page I could find and all come back to the same problem.
I have ISP A on port 1 and ISP B on port 2. In my routes I have ISP A distance 1 and ISP B distance 2. Even if I unhook the ISP A form the incoming connection. My script will run and will change ISP A distance to 3 however it still get pings out of port 1 and thus runs the up script. Below is a copy of what script I have been trying to run. AS i said the scripts run and work but why can I still ping out a port that has no ISP connection? It gets a ping through about every 15th try. Then the next problem I see is if the ISP does come up I still do not get 5 pings in a row for the script to run to switch back the distance.
script 1:
:local i 0; {:do {:set i ($i + 1)} while (($i < 5) && ([/ping 64.233.169.99 interval=3 count=1]=0))};
:if ($i=5 && [/ip route get [find comment="Default Route"] distance]=1) do={:log info "Main Gateway down";
/ip route set [find comment="Default Route"] distance=3}
script 2:
:local i 0; {:do {:set i ($i + 1)} while (($i < 5) && ([/ping 64.233.169.99 interval=3 count=1]=1))};
:if ($i=5 && [/ip route get [find comment="Default Route"] distance]=3) do={:log info "Main Gateway up";
/ip route set [find comment="Default Route"] distance=1}