Community discussions

MikroTik App
 
rodrigotoledo11
just joined
Topic Author
Posts: 1
Joined: Thu Nov 30, 2017 12:04 am

Failover Script

Thu Nov 30, 2017 12:07 am

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
 
User avatar
jprietove
Trainer
Trainer
Posts: 212
Joined: Fri Jun 03, 2016 3:00 pm
Location: Cádiz, Spain
Contact:

Re: Failover Script

Thu Nov 30, 2017 8:09 pm

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:

Code: Select all

ip route add gateway=10.0.0.1 check-gateway=ping
ip route add gateway=10.0.0.2 distance=5
 
TomosRider
Member Candidate
Member Candidate
Posts: 209
Joined: Thu Nov 20, 2014 1:51 pm

Re: Failover Script

Fri Dec 01, 2017 6:22 pm

check-gateway ping is a solution.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10234
Joined: Mon Jun 08, 2015 12:09 pm

Re: Failover Script

Fri Dec 01, 2017 6:53 pm

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.

Who is online

Users browsing this forum: GoogleOther [Bot] and 57 guests