I wrote a script for seamless failover (useful for WebRTC) and it works flawlessly switching from ISP1 to ISP2.
But I noticed something strange.
When I send 3 pings with a timeout of 100ms, then every 3 hours there is no response from the destination IP. So unnecessary failover occurs.
When I send 3 packets with a timeout of 200ms, then every 6 hours, there is no response from the destination IP.
What could be the cause of this?
Code: Select all
:local i false
:local j true
:local ipaddr 1.1.1.1
#ISP1 TTL must equal ISP2 TTL
do {
if (([/ip route find distance=1]=0) || ([/ping $ipaddr count=3 size=32 interval=200ms interface=ether1]=0)) do={
if (j=true) do={
/ip dhcp-client set ether1 default-route-distance=3;
/ip firewall connection remove [find];
:set i true;
:set j false;
:log warning "ISP1 down!Failover!";}
} else={
:if (i=true) do={
/ip dhcp-client set ether1 default-route-distance=1;
/ip firewall connection remove [find];
:set i false;
:set j true;
:log warning "ISP1 up!";}
}
} while=(i=i)
Also I managed to crash RouterOS 6.49 with a similar script.)