Community discussions

MikroTik App
 
illiniwireless
Member Candidate
Member Candidate
Topic Author
Posts: 152
Joined: Mon Dec 26, 2005 12:36 am
Location: USA

failover script from wiki

Sun Jun 24, 2007 8:25 am

Here is the original script in the wiki:

:local i 0; {:do {:set i ($i + 1)} while (($i < 5) && ([/ping 72.14.207.104 interval=3 count=1]=0)};
:if ($i=5 && [/ip route get [find comment="Default Route"] disabled]=false) do={:log info "Main Gateway down";
/ip route set [find comment="Default Route"] disabled=yes}


:local i 0; {:do {:set i ($i + 1)} while (($i < 5) && ([/ping 72.14.207.104 interval=3 count=1]=1)};
:if ($i=5 && [/ip route get [find comment="Default Route"] disabled]=true) do={:log info "Main Gateway up";
/ip route set [find comment="Default Route"] disabled=no}

These scripts did not work for me and ether 1 was the interface I was trying to control. I also changed the IP address to DNS server IP that we use outside our network. Here is my script which will make it failover if the DNS is not reachable but when ether 1 is back up it won't switch back from ether 8. Since it is disabled it doesn't see any farther than the dsl modem. I just paste this in netwatch, changed ping to 100ms and interval of 3ms. Please tell me what to do. Thanks

:local i 0;:if [/ip route get [find comment="Default Route"] disabled]=false) do={:log info "Main Gateway down";
/ip route set [find comment="Default Route"] disabled=yes}

:local i 0; :if [/ip route get [find comment="Default Route"] disabled]=true) do={:log info "Main Gateway up";
/ip route set [find comment="Default Route"] disabled=no}
 
illiniwireless
Member Candidate
Member Candidate
Topic Author
Posts: 152
Joined: Mon Dec 26, 2005 12:36 am
Location: USA

Re: failover script from wiki

Sun Jun 24, 2007 8:33 am

I forgot to mention the way I tested this setup. I would change the timeout ms to a lower number than it was running and it would switch to the backup link but when I raised it back to 100ms it wouldn't change back since it is trying resolve this address in a disabled interface but it will resolve the dsl router whick is 192.168.1.1

Thanks
 
illiniwireless
Member Candidate
Member Candidate
Topic Author
Posts: 152
Joined: Mon Dec 26, 2005 12:36 am
Location: USA

Re: failover script from wiki

Sun Jun 24, 2007 9:53 am

I got it to work. I will post it on WIKI.
 
illiniwireless
Member Candidate
Member Candidate
Topic Author
Posts: 152
Joined: Mon Dec 26, 2005 12:36 am
Location: USA

Re: failover script from wiki

Mon Jun 25, 2007 12:14 am

I do have this failover working but will be making improvements. Instead of disabling main gateway I will change its distance to make it switch routes. This will allow me to monitor main gateway until it is available and then switch back. Anyone with ideas please post them to help speed up the process.

Thanks
 
WirelessRudy
Forum Guru
Forum Guru
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: failover script from wiki

Sat Aug 11, 2007 4:05 pm

Your improved script in the Wiki works fine, ..... but what if you don´t have reliable node to ping?
I tried to replace your IP to ping from Google to my dns servers, my ISP gateway, any other major website, but over time they al face hickups and don't return pings.
What about to build in the script a second or third node to ping and only if they all fail the route cost to be re-written?

I'm not a star, better I'm a dummy, on scripts so can we help eachother?

Future step will be to use three gateways.

And what about loadbalancing if both gateways are functioning normal. Only fail back if one drops? This will be very interesting!

Rudy
 
galaxynet
Long time Member
Long time Member
Posts: 646
Joined: Fri Dec 17, 2004 2:52 pm
Contact:

Re: failover script from wiki

Mon Aug 13, 2007 1:07 pm

Rudy - I v'e dropped you two emails in the past few days to: Marusol [marusol@fastmail.fm] you haven't replied? So I am guessing that you did not receive the emails. Do you have another email server that I can send my replies to?

thom.lawless [at] rapidwifi.com

Thom
 
WirelessRudy
Forum Guru
Forum Guru
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: failover script from wiki

Mon Aug 13, 2007 4:23 pm

Rudy - I v'e dropped you two emails in the past few days to: Marusol [marusol@fastmail.fm] you haven't replied? So I am guessing that you did not receive the emails. Do you have another email server that I can send my replies to?

thom.lawless [at] rapidwifi.com

Thom
Hi Thom, glad to see you. Dropped you an mail again. Hope to correct my providers settings. CU