Community discussions

MikroTik App
 
ashpri
Member Candidate
Member Candidate
Topic Author
Posts: 143
Joined: Sun Oct 14, 2018 3:11 am

Script for recursive failover based on packet loss

Fri Sep 23, 2022 4:22 am

Recursive failover has been working perfect for my connection with 2 ISPs. Last week my main ISP experienced intermittent issues. You could still ping but it was intermittent with latency spikes. I ended up having to disable (renumber) the route manually.

How would I apply recursive failover by checking for packet loss?

I suppose the script logic would be:
1. Check 8.8.8.8 (recursive for ISP1) & 8.8.4.4 (recursive for ISP2)
2. Ping 8.8.8.8 or 8.8.4.4 ten times
3. If packet loss >=20% then find route by comment and disable
4. If packet loss <20% then find route by comment and enable

Are there past topics that you can refer me to.

Thank you.
Last edited by ashpri on Fri Sep 23, 2022 4:51 am, edited 1 time in total.
 
ashpri
Member Candidate
Member Candidate
Topic Author
Posts: 143
Joined: Sun Oct 14, 2018 3:11 am

Re: Script for recursive failover based on packet loss

Fri Sep 23, 2022 4:39 am

That logic would not work. Once you disable a route you can't check whether it is back to normal.

Updated logic:

1. Ping 8.8.8.8 (recursive for ISP-1) 20 times

2. If packet loss = 0%,
do nothing

3. Else If packet loss >= 20% and route to ISP-1 (find by comment) distance = 1,
find route to ISP-1 (find by comment) and change distance to 91

4. Else if packet loss = 0% and route to ISP-1 distance != 1,
find route to ISP-1 and change distance to 1

I would then have a similar script for ISP-2 except the distances would be different.

Do you agree with the script logic?
 
ashpri
Member Candidate
Member Candidate
Topic Author
Posts: 143
Joined: Sun Oct 14, 2018 3:11 am

Re: Script for recursive failover based on packet loss

Fri Sep 23, 2022 9:33 am

FYI this is the relevant screen in fortigate to achieve the above.
You do not have the required permissions to view the files attached to this post.

Who is online

Users browsing this forum: No registered users and 11 guests