Autofail over with 2isp dynamic ip

Hello,
I was looking here and there is nothing or I can’t find it so if someone can point me where to find it.
What I have a hap rb, and I need to connect 2 gsm modem and if one goes down the second one take all traffic.
I have found some scripts but all is for static ip adresses. My booth ISP have dynamic Ip, so I don’t know how to do that with dynamic IP from ISP.
So situation is like this:

1 ISP modem----- dynamic IP
—mikrotik Hap------lan users
2 ISP modem-----dynamic IP

Thank you

typical basic situation
dst-address=0.0.0.0/0 gwy=gatewayof ISP1 check-gateway=ping distance=5
dst-address=0.0.0.0/0 gwy=gatewayof ISP2 distance=10


What this does is choose is force the router to use ISP one due to a shorter distance marking,
the router will continually ping to make sure the gateway is up.
If it goes down then it will switch to the second connection but keep checking to see if the first one is backup yet.

This method does not rely on a fixed IP address from the ISPs, but it does rely on their gateway addresses being fixed. If the gateway is dynamic as well, and issued to you by DHCP or LCP or something then I don’t think the normal method can be used.

Thanks guys ,
I thing the gateway is dynamic too. So this solution is not good or it is?

In that case, perhaps a script in the DHCP client settings is the way to go…
Along with what was provided above.

I have no idea what this does but it is one OPTION I have seen. Its is put in the IP DHCP client advanced settings…

:local count [ /ip route print count-only where dst-address=0.0.0.0/0 routing-mark=$rmark ]
:if ($bound=1) do={
:local iface $interface
:local gw [ /ip dhcp-client get [ find interface=$“iface” ] gateway ]
:set gw “$gw%$iface”
:if ($count=0) do={
/ip route add gateway=$gw routing-mark=$rmark
} else={
if ($rmark=“main”) do={
/ip route set [ find dst-address=0.0.0.0/0 !routing-mark gateway!=$gw ] gateway=$gw
} else={
/ip route set [ find dst-address=0.0.0.0/0 routing-mark=$rmark gateway!=$gw ] gateway=$gw
}
}
} else={
:if ($rmark=“main”) do={
/ip route remove [ find dst-address=0.0.0.0/0 !routing-mark gateway~“%$interface$” ]
} else={
/ip route remove [ find dst-address=0.0.0.0/0 routing-mark=$rmark type=unicast ]
}
}


+++++++++++++++++++++++++++++++

Or much simpler version of that, add everything as if it was static config, mark route(s) using unique comments, and then use lease script to only update gateway. Example:

http://forum.mikrotik.com/t/routing-filters-fixes-request/154210/10

Okay lets parse that out… with some modifications…

/ip route add dst-address=0.0.0.0/0 gateway=dynamicWANIP1 comment=“dhcp1table=main
/ip route add dst-address=0.0.0.0/0 gateway=dynamicWANIP2 comment=“dhcp2table=main


Then GO the the respective IP DHCP Client settings and set add-default-route=no for dhcp client and use lease script to update the route you added
For WAN1

:if ($bound=1) do={
  /ip route set [find where comment="dhcp1"] gateway=$"gateway-address" disabled=no
} else={
  /ip route set [find where comment="dhcp1"] disabled=yes
}

FOR WAN2

:if ($bound=1) do={
  /ip route set [find where comment="dhcp2"] gateway=$"gateway-address" disabled=no
} else={
  /ip route set [find where comment="dhcp2"] disabled=yes
}

Every time the IP is bound, the new gateway will be inserted into the IP route.

thank you, for your help, I will try your advice, I am not an expert so a will give a try if will success will let you know, Not sure if all understood but you gave me a good start point
thank you,

Hello,
Thanks all of you guy but I’m really struggling with all configuration, I am not sure but there is many way to achieve the goal.
I am little bit confused in all that, can you explain me what all I have to do for it. We can make an agreement too, so please if someone can help.
Thank you

Thanks to “anav”


He solved my problem and be a big help.
Thank you all guys too.

anav thank you once again

No worries, I dedicate my assistance to the good people of Ukraine, if we could just all get along and help one another!!!