Feature Request dhcp-client: add-default-route-to-table

Hi,

I want to submit a feature request for a dhcp-client option I want to call add-default-route-to-table.

I want to use the explanation from http://wiki.mikrotik.com/wiki/Routing_via_a_DHCP_allocated_gateway:

Sometimes a box can have a DHCP allocated address, but the gateway for that address is not automatically configured as the default gatway - perhaps you only want to route certain traffic out via that interface or maybe you have two routes out and need to route some traffic one way and others the other.

Having an option for the dhcp-client, e.g. called add-default-route-to-table, to control with which routing mark or in which routing table the default route will be added into the routing table would make it much easier in a lot of cases and would avoid scripting as shown in the link above.

Additionally, the OSPF routing part already has an option called routing-table doing exactly that (See http://wiki.mikrotik.com/wiki/Manual:Routing/OSPF). Even though not knowing the implementation details, I think it could be easily added to the dhcp-client, too.

So, what do you think? :slight_smile:

Regards,
Robert

This feature is useful when VRFs are used. If interface on which DHCP client is configured belogs to VRF then default route will be added to VRF routing table.

i think you can use the ‘dynamic-in’ chain in routing filters to accomplish this, however its global and not per dhcp-client.

Hi,

@mrz: Do you mean, adding the interface to an vrf instance the default route from dhcp-client should be added with the corresponding routing-mark? Well, I just tested it, and the default route will not get into the routing table with the routing-mark set. So indeed, using VRF a new option for the dhcp-client could handle this scenario in a nice way, as the default gateway in the main routing table is completely useless because it isn’t reachable from there.

> /ip dhcp-client print detail 
Flags: X - disabled, I - invalid 
 0   interface=ether1 add-default-route=yes default-route-distance=1 use-peer-dns=yes use-peer-ntp=yes status=bound address=192.168.2.26/27 gateway=192.168.2.1 dhcp-server=192.168.2.1 primary-dns=192.168.2.1 
     primary-ntp=192.168.2.1 expires-after=1w2d23h55m14s

> /ip route vrf print detail 
Flags: X - disabled, I - inactive 
 0   routing-mark=myroutingmark interfaces=ether1

> /ip route print detail 
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit 
 0 ADC  dst-address=192.168.2.0/27 pref-src=192.168.2.26 gateway=ether1 gateway-status=ether1 reachable distance=0 scope=10 routing-mark=myroutingmark 

 1  DS  dst-address=0.0.0.0/0 gateway=192.168.2.1 gateway-status=192.168.2.1 unreachable distance=1 scope=30 target-scope=10

@changeip: Well, this will work as you mentioned in a really global fashion only (all dhcp-clients default routes get the same routing-mark). This doesn’t cover cases, with multiple dhcp-uplinks. Doing load balancing over these lines I want each default gateway in a separate routing-table/routing-mark. So I gain full control beeing able to route different traffic over different dhcp-uplinks. At the moment you have to set add-default-gateway=no for each dhcp-client, add static default-routes with different routing-marks and update the gateways of these default routes with the script shown above… :frowning:

> /ip dhcp-client print detail 
Flags: X - disabled, I - invalid 
 0   interface=ether1 add-default-route=yes default-route-distance=1 use-peer-dns=yes use-peer-ntp=yes status=bound address=192.168.2.26/27 gateway=192.168.2.1 dhcp-server=192.168.2.1 primary-dns=192.168.2.1 
     primary-ntp=192.168.2.1 expires-after=1w2d23h59m23s

> /routing filter print detail 
Flags: X - disabled 
 0   chain=dynamic-in invert-match=no action=passthrough set-routing-mark="myroutingmark"

> /ip route print detail 
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit 
 0 ADS  dst-address=0.0.0.0/0 gateway=192.168.2.1 gateway-status=192.168.2.1 reachable ether1 distance=1 scope=30 target-scope=10 routing-mark=myroutingmark 

 1 ADC  dst-address=192.168.2.0/27 pref-src=192.168.2.26 gateway=ether1 gateway-status=ether1 reachable distance=0 scope=10

So an additional configuration option for the dhcp-client would make things much easier. :sunglasses:


Regards,
Robert

Hallo!

I’m just wondering if this feature been added yet?

As someone coming from the Cisco world, I’m a little surprised to not find such a small thing already implemented :slight_smile:

It seems that changing default route metric (at DHCP client) and then filtering by that enables per DHCP route marks…