Feature request: routing via dynamic gateway w/out scripting
Posted: Tue Feb 22, 2011 10:20 am
The problem
There is a way to set up load balancing with failover without scripting described here: http://wiki.mikrotik.com/wiki/Advanced_ ... _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):
/ip route add dst-address=<gateway-alias>/32 gateway=<real-gateway> distance=1 scope=10 target-scope=10
This route will be automatically removed when the connection is going down (the connected route is removed). So we can use <gateway-alias> 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.
There is a way to set up load balancing with failover without scripting described here: http://wiki.mikrotik.com/wiki/Advanced_ ... _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:
Code: Select all
/ip route
add dst-address=Host1 gateway=GW1 scope=10
add dst-address=Host2 gateway=GW2 scope=10
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):
/ip route add dst-address=<gateway-alias>/32 gateway=<real-gateway> distance=1 scope=10 target-scope=10
This route will be automatically removed when the connection is going down (the connected route is removed). So we can use <gateway-alias> 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.