Dhcp_range option


I have a need to assign a specific group of devices (Iot) IPs in a specific range that is outside the regular range that I've entered in Luci for the rest of the network.

This has been working fine for quite a while by adding to /etc/config/dhcp under config dnsmasq:

       option confdir '/etc/dnsmasq.d'

and then adding to that file:


I need this file in a place that doesn't get lost between reboots and startups so as to avoid writing it each time, and restarting dnsmasq etc.

Recently I had an issue with policy based routing (pbr) which stangri fixed quickly. The issue being that pbr assumed the location was the default. This made me think that there may well be other packages I may decide to use that may only consider the default location, and may not be as responsive as stangri.

With that said, my question is: How can I incorporate this into the default dhcp config file without using conf-dir?

I noticed that the openwrt wiki specifically mentions my use case by saying for tags:

List of tags that dnsmasq needs to match to use with --dhcp-range.

However, there is no mention of dhcp-range anywhere.
Before I experiment, wondering if anyone already has this setup... Would it be simply:

config dhcp 'lan'
 list dhcp_range 'tag:iot-no-internet,,,3h'
 list dhcp_range 'tag:iot-yes-internet,,,3h'


If you did tag your hosts e.g.:

config host
	option name 'client1'
	option mac '00:21:63:75:aa:17'
	option ip ''
	option tag 'iot-no-internet'

Then yes that should/could work :slight_smile:

Ok I'll try it when I get a chance / family allows. Have you actually tried that setup and it works?

The reason I ask is that since posting I found a couple of things:

These couple of posts from a different forum seems to indicate that it doesn't work.

Also looked at the code and there's no handling to convert the openwrt entry ("dhcp-range" or similar) to dhcp_range entries beyond the one that is built based on the single Luci entry page for the interface.

I have not tried it myself so do not try it in a production environment

Edit: just tried it and it does not work :frowning:

Thanks for beating me to it.
Yeah makes sense, as there's nothing in the code to decipher that. Unfortunate.

For future reference, found this very good thread in which eduperez and slh provided good hint:

The intention is that you should use "/etc/config/dhcp" for general options supported by uci / LuCi, and "/etc/dnsmasq.conf" for other specific options not supported by uci / LuCi.

I guess will have to directly update /etc/dnsmasq.conf so as to avoid writing as part of startup and an avoidable dnsmasq restart.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.