The problem
There is a way to set up load balancing with failover without scripting described here: http://wiki.mikrotik.com/wiki/Advanced_Routing_Failover_without_Scripting. All is working fine. We may use “virtual” hops and rely on recursive nexthop lookup. However in order to make it working, we have to define at least one route that points to the real gateway. Here is an example from the mentioned article:
GW1 and GW2 must be ip addresses. If we use interface names here, recursive nexthop lookup will not be working. But what to do in cases when a gateway address may change? If we reconnect to ISP and get a new gateway address, all our static routes related to that ISP will become inactive because they are still using an old gateway address.
There is a workaround for that if we connect to ISP using ppp (pppoe, pptp, l2tp, etc). We can specify a static remote ip address for particular connection in the ppp profile. But what to do in case of getting a dynamic gateway address via DHCP? We can use scripting here and change all the related routes according to the new gateway address. But I think the OS specially designed for routing should allow to do such things without scripting, shouldn’t it?
The solution
I would propose to add the following new option to dhcp-client, pppoe-client, l2tp-client and all other clients:
gateway-alias (IP; Default: “”)
If this option is specified, Router OS will automatically add the following dynamic route to the routing table when the connection is going up (the connected route is added):
This route will be automatically removed when the connection is going down (the connected route is removed). So we can use as a gateway in our static routes and there is no need to change routes any more even if the real gateway is dynamic. Moreover, using this approach we can change ISP without need to change any static routes at all.
That is true if the previous gateway is in the same network as a newly assigned ip address. Otherwise it will not work. Example of possible load balancing in the same broadcast segment:
It’s strange not to see other comments, especially from MT team. This question has been asked many times and every time a script has been suggested as a solution:
I believe my solution is simple to use, easy to implement and completely solves the problem of policy routing via dynamic gateway. Would it be correct if I e-mail this feature request to support@?
If an pppoe/pptp/l2tp client on RouterOS wants to always use a static remote ip address specified in a ppp profile, can an ISP deny doing that or not? Does anyone know for certain?
This has been several time in last few years but Mikrotik stuff is categorical not to add such option.
Even windows has it. When you set DHCP client there is simple check box to choose wether to automatically add DHCP provided gateway as default gateway or not. You can even set metrics for that default route.
Hello janisk,
I’m new with mikrotik,believe… your reply only for dhcp-client(is it?), my point is solution for “pppoe-client”. i really need it for load balancing with failover without scripting.
I’m not try that yet(Can i?,with mikrotik) because my ISP always provide dynamic ip(if i need static ip..have to pay more:( ). So what do you suggest?
Hello, It is not possible because of current nexthop resolution algorithm. There will be a lot of improvements in version 6, > so most likely this feature will also be added. > You can try looking in our wiki > http://wiki.mikrotik.com/wiki/User/Routing > There are a lot of load balancing examples, for example, “ECMP Failover Script” Regards, Maris B. 10/23/2014 15:27
Thank you very much Maris,I hope so…very soon.What took you so long? Ohh…Mikrotik.