Page 1 of 1

Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Fri Sep 02, 2016 9:39 pm
by TLS
I am trying to figure out how to implement WAN failover with 2 different ISP's - A Comcast connection providing a static IP and a Century Link connection providing a dynamic IP.

I believe I've figured out how to accomplish this if both were static, correct me if I am wrong, under IP Addresses I would simply assign ether1 and ether2 their own static IP's and then under System Scripts I would add this script (http://wiki.mikrotik.com/wiki/Failover_Scripting) and edit where necessary.

I can purchase a static from Century Link if I have to but would prefer not to. Any help or suggestions would be much appreciated, thanks.

Re: Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Sat Sep 03, 2016 11:45 am
by shailparmar
you can simply do fail over without scripting, by define gateway route distance.
set primary connection gateway route distance to 0 and back up connection route distance to 1.
if 0 route is unreachable router automatic enable route 1.

Re: Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Sat Sep 24, 2016 8:58 pm
by tabate47
If you do it that way, how can you get notified via email?

Re: Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Mon Sep 26, 2016 4:58 am
by tarikin
If you do it that way, how can you get notified via email?
Use netwatch tool, add a gateway's known static ip address to watch list and define e-mail scripts for UP and DOWN events.
This article may help you:
http://gregsowell.com/?p=819

Re: Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Mon Sep 26, 2016 6:09 am
by tabate47
Gateway has dynamic ip!

Re: Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Mon Sep 26, 2016 10:41 am
by che
You didn't state what type of WAN connection you have on dynamic gateway, so I'll just assume it's DHCP client. Since you would like to keep the script from wiki, replace current static variable with new one that reads acutal gateway value, and schedule script to run in a reasonable interval (15 minutes for example, if your IP changes frequently):

Old variable:
:local GatewayISP2 2.2.2.2
New variable (assuming you have only one DHCP client):
:local GatewayISP2 [/ip dhcp-client get value-name=gateway number=0];

Re: Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Mon Sep 26, 2016 3:19 pm
by tabate47
Yes, it is dhcp client, but I have 2 dynamic dhcp clients.

Can it still be done?

Re: Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Tue Sep 27, 2016 10:35 am
by che
Sure it can.

You need to find out exact order of DHCP clients. Afaik, you can not do that from Winbox (you can only assume list position, but it's not numbered), so you have to open new terminal either from Winbox or use telnet/ssh, and enter this command:
ip dhcp-client print
If DHCP client you want is with number "0" then you don't have to edit anything from my previous post, but if it's under "1" - you will have to replace "number=0" with "number=1".

Re: Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Tue Sep 27, 2016 1:30 pm
by tarikin
Got a new idea =)
Try to define a static route to any random pingable ip (like 8.8.8.8) thu a certain interface gateway. As i know, ROS is able to determine a gateway's IP it was set dynamically via DHCP Client.
Next is netwatch the 8.8.8.8.
Once the static route is set, the 8.8.8.8 shouldn't be able to be reachable thru another gateway and netwatch reports "Down" status.

Another way is to find out any local provider's ip that is reachable only from local network and netwatch it =)

Re: Dual Wan failover with 1 static and 1 dynamic IP?

Posted: Tue Sep 12, 2017 2:33 am
by thewickerman666
Take a look at InoX's solution works for me. You may need to modify for the static wan

viewtopic.php?f=2&t=93222&p=617854#p617854