LUCI - add support for managing tags in DHCP and DNS configuration web page

Hello,
I use tags in dnsmasq configuration for adding specific DCHP options to static leases.

I can assign existing freeform tags to static leases form the web page, but I have to add the tags manually in the configuration.

So, it would be nice if there was a way for adding/ removing/ editing tags using the DHCP and DNS configuration web page, instead of having to add them using uci or by manually editing the /etc/config/dhcp file.

Thank you in advance,
Panos

2 Likes

I apologize as I don't intend to take this thread away from your request, but I was not aware of this functionality and I have a question if you don't mind.

Do these tags allow you to send out DHCP Option 6 to certain clients for specific DNS addresses, while sending out another DHCP Option 6 to other clients for specific DNS addresses?

I spent some time reading the dnsmasq manpage after seeing your post here. But I have to admit, I feel confused about it to a certain extent. If you could possibly share a couple of snippets/examples of how you use it, that would be appreciated. Thank you.

It works in the following way:

you add a tag with the dhcp option you want in the configuration
ex.

subnet mask 255.255.255.0 , gateway 192.168.151.10, dns servers 192.168.151.10 and 192.168.151.11

config tag 'net2'
	list dhcp_option '1,255.255.255.0'
	list dhcp_option '3,192.168.151.10'
	list dhcp_option '6,192.168.151.10,192.168.151.11'

route 192.168.1.0/24 -> 192.168.151.10 and route 192.168.124.34/32 -> 192.168.151.11

config tag 'route3'
	list dhcp_option '121,192.168.1.0/24,192.168.151.10,192.168.124.34/32,192.168.151.11'

and then in the web interface you add these two tags, net2 and route3 (both or one of them) to the static leases/hosts/clients you want to use them and for example the hosts configuration looks like this:

config host
	option name 'testPC2'
	option mac '12:34:56:78:9a:bc'
	option ip '192.168.151.61'
	option leasetime '12h'
	list tag 'net2'
	list tag 'route3'

The second part, adding tags to the host already works from the web gui.
The first part, creating the tag does not work from the web gui, this is what i asked for.

1 Like

Thank you so much, I appreciate it. Seeing your examples in OpenWrt-specific dhcp config format definitely helps me understand it much better now. This is fantastic. Lots of possibilities with tags which is great.

I would also like to second your feature request. I think having this functionality within LuCI to manage tags better would be good to have.

This is something I've been working on for a while. The work must be done in small steps, otherwise reviewers just get overwhelmed and there is no progress.

The process is going slowly due to time restraints of other volunteers who review and accept the PRs.

Goals of the GUI improvements are better clarifying tags, as well as fixing some bugs I've identified.

3 Likes

Here's an example:

2 Likes

This is loosely related, but is there a way to render hostnames specific to certain MAC addresses or local IP addresses:

2 Likes

Is there a link to this code in progress?

It's just a matter of creating/clarifying/fixing a "Hostname tags" tab, correct?

Did not understand. Did you mean find hostnames associated to a particular IP?

Not yet, but it's not difficult to find.

Is the ask of this FR just to have one central place that lists all the tags in use? I've thought of adding this, but I question its limited helpfulness: you can see them but you can't do much else with them.

What is this intended to help with? To find where they're used?

As in, can you tell OpenWrt to return specific IP addresses corresponding to certain hostnames in respect of only particular LAN devices? So say to retun for youtube.com 216.239.38.120 only if the requesting LAN device is 192.168.1.200.

That was impossible to understand without your example.

I am not sure whether that is possible in dnsmasq. I've never tried. The configurability of dnsmasq suggests to me it could be possible.

https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

Edit: the only conceivable way I can think of right now is to run two instances of dnsmasq, each on a separate IP. Send that separate IP as a special DNS option --dhcp-option to a --dhcp-mac using a unique tag. Associate those host records with a particular dnsmasq instance. But today there is no way to define host records to a dnsmasq instance... the way things are today, is that those domain entries end up in the HOSTFILE for each instance.

Otherwise check --dynamic-host usage. It's not far off.

Yes, I have this case covered in my patch-set - it is not in master yet - and things will change before it finally arrives:

Setting up the tags:

5 Likes

Thank you very much!
It is exactly what I need.

1 Like

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