Community discussions

MikroTik App
 
DotTest37
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Sun Oct 06, 2013 10:01 pm

Preventing failback when main ISP is flapping

Tue Jun 28, 2016 9:04 pm

I have this customer with dual WAN, ISP1 and ISP2.
ISP1 is a fiber Internet link, with 60 Mbit download and low latency.
ISP2 is a regular DSL, 20 Mbit download, twice as much latency.

ISP1 is primary, and ISP2 is used only for failover, in case ISP1 goes down.
Both ISP1 and ISP2 provides static public IPs and the PCs behind the MT router are all NAT using masquerade.

I wrote a script that check for three external IPs every 5 seconds, when all three fail, then ISP1 is declared DOWN and the default route is moved to ISP2.
(I have static routes for the three IPs I use for checks, so they are forced to go via ISP1 at all times)

As soon as ISP1 comes online (any of the three IPs ping) then the default changes again to ISP1.

Last weekend I noticed that ISP1 was flapping, coming Offline/Online, several times in a period of 5 minutes, so my script was failing over and failing back very quick.
If that would happen during business hours and ISP gets unstable for long, the office will be pretty much down, as the MT router will be swtiching back and forth all the time.
Any suggestions on how to address the issue?
I was thinking to add some logic on the script to start a counter after failover, so when ISP1 comes online then it waits for lets say, 5 minutes before failback, if within those 5 minutes ISP1 has issues, then the counter will reset and start again,, preventing failback until ISP1 is stable.
Maybe I could add checks for latency also, not sure.

Any ideas on how to prevent rapid failback on potentially unstable links?

Thanks!
 
jarda
Forum Guru
Forum Guru
Posts: 7603
Joined: Mon Oct 22, 2012 4:46 pm

Re: Preventing failback when main ISP is flapping

Thu Jul 14, 2016 8:25 am

You need to manage it by script. Let say you run the script each 5 seconds. When you switch to backup, set some counter to zero and each time the script would like to switch back, it rises the counter value by 1. When any problem with first wan is detected, counter is reset to zero again. When the counter reaches 60 or whatever number you consider to be appropriate, it switches the routing back to first wan.
 
DotTest37
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 56
Joined: Sun Oct 06, 2013 10:01 pm

Re: Preventing failback when main ISP is flapping

Fri Aug 05, 2016 10:41 pm

Hi

Where would I find an example of such counter?
Im not sure where to start.
Thanks!
 
jarda
Forum Guru
Forum Guru
Posts: 7603
Joined: Mon Oct 22, 2012 4:46 pm

Re: Preventing failback when main ISP is flapping

Wed Aug 10, 2016 5:49 pm

You need to declare it as public variable by script.

Who is online

Users browsing this forum: Bing [Bot], bpwl, censored224, kareztt, mivsek and 126 guests