Hello guys, I need to do a failover script in the following conditions:
The script need to check package loss in the main link every x times and, if the link is down or losing y% packages, the mikrotik is set to use the second link. In this condition, every x time the mikrotik need to ping the main link and check is the package loss is acceptable. If its is, then the main link is set to active again. How to do this?
Sorry my bad english.
I am not a specialist
Thanks
Have you considered using ‘check-gateway=ping’? From the wiki (https://wiki.mikrotik.com/wiki/Manual:IP/Route) “Periodically (every 10 seconds) check gateway by sending either ICMP echo request (ping) or ARP request (arp). If no response from gateway is received for 10 seconds, request times out. After two timeouts gateway is considered unreachable. After receiving reply from gateway it is considered reachable and timeout counter is reset.”
As an example, let’s say you have two default gateways: Main (10.0.0.1) and backup (10.0.0.2). You want to use 10.0.0.1 but, if it is down, then use 10.0.0.2
You can use ‘distance property’ to prefer 10.0.0.1 over 10.0.0.2:
ip route add gateway=10.0.0.1 check-gateway=ping
ip route add gateway=10.0.0.2 distance=5
check-gateway ping is a solution.
I don’t think you can configure an “acceptable loss percentage” with check-gateway=ping
It is either up or down depending on any ping replies coming back.
I think the topic starter wants to be able to switchover when the link is degraded.
it should be possible to write a script that does that, but it will require some work.