Interface dns_search list params not being passed via DHCP to clients?

i've a client properly getting IPv4 via DHCP, but the search domains are not getting passed from /etc/network/config down to dnsmasq it seems, as they never appear on the client's /etc/resolv.conf

relevant contents of /etc/config/network
config interface 'lan'
        option device 'br-lan.2220'
        option proto 'static'
        option ipaddr '172.22.20.1'
        option netmask '255.255.255.0'
        list dns_search 'mgmt.home.my.domain'
        list dns_search 'lan.home.my.domain'
-
and here's the dnsmasq instance section from /etc/config/dhcp
config dnsmasq 'lan_dns'
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan.home.my.domain/'
        option domain 'lan.home.my.domain'
        option localuse '0'
        option expandhosts '1'
        option cachesize '1000'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases.lan'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        list interface 'lan'
        list notinterface 'loopback'
        list rebind_domain '/my.domain/'
        option localservice '1'

config dhcp 'lan'
        option instance 'lan_dns'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv4 'server'

What i don't get is why mgmt does not end up appearing anywhere in

/tmp/etc/dnsmasq.conf.lan_dns
# auto-generated config file from /etc/config/dhcp
conf-file=/etc/dnsmasq.conf
dhcp-authoritative
domain-needed
localise-queries
read-ethers
enable-ubus=dnsmasq.lan_dns
expand-hosts
bind-dynamic
local-service
cache-size=1000
domain=lan.home.my.domain
local=/lan.home.my.domain/
interface=br-lan.2220
except-interface=lo
addn-hosts=/tmp/hosts
dhcp-leasefile=/tmp/dhcp.leases.lan
resolv-file=/tmp/resolv.conf.d/resolv.conf.auto
stop-dns-rebind
rebind-localhost-ok
rebind-domain-ok=/my.domain/
dhcp-broadcast=tag:needs-broadcast
conf-dir=/tmp/dnsmasq.d
user=dnsmasq
group=dnsmasq

dhcp-ignore-names=tag:dhcp_bogus_hostname
conf-file=/usr/share/dnsmasq/dhcpbogushostname.conf

bogus-priv
conf-file=/usr/share/dnsmasq/rfc6761.conf
dhcp-range=set:lan,172.22.20.100,172.22.20.249,255.255.255.0,12h

probably some conflicting/behaviour-altering parameter i'm overlooking?

You don't have any configured.

Name Type Default Option Description
domain domain name (none) -s DNS domain handed out to DHCP clients

From: https://openwrt.org/docs/guide-user/base-system/dhcp#all_options

i was under the impression having it specified for each interface /etc/config/network does the same thing? are you saying i need to manually create dhcp-options also/instead ?

I'm not sure what you mean by the phrase "specified for each interface /etc/config/network does the same thing" - as noted, the config in question would be added to /etc/config/dhcp

No, I'm saying you need to configure the Option I noted above:

(EDIT: removed incorrect config section, fixed in post below)

i thought this belongs in the dnsmasq section not the dhcp section (which i have set)? at least that's where luci put it..

btw i'm also referring to the multiple search domains, not the dhcp-scope's main domain

update - i was under the impression adding it to the network interface's "dns_search" list would end up creating dhcp-option 119 (i could always set that manually elsewhere, but thought the former would be a cleaner way to specify that)

1 Like

To be clear. You want a client to:

  • Get an IP
  • And also have a search domain of "lan.home.my.domain"

So that executing nslookup foo results in a resolution of foo.lan.home.my.domain instead - correct?

Correct, my apologies. I was confused by your specification of multiple instances (but only showing 1 instance).

config dnsmasq 'lan_dns'
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan.home.my.domain/'
        option domain 'lan.home.my.domain' #<---correct
        option localuse '0'
        option expandhosts '1'
        option cachesize '1000'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases.lan'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        list interface 'lan'
        list notinterface 'loopback'
        list rebind_domain '/my.domain/'
        option localservice '1'

You should have been able to edit the default config of 'lan' to the domain you desire.

that's the primary domain yes, but that's not what i'm after.. i'm after being able to specify additional domains with which the client receives via dhcp to append to queries if the primary fails.. basically equivalent of dhcp option 119.. rather than manually add and number this option - i thought adding it to /etc/config/network (interface section) as such:

        list dns_search 'mgmt.home.my.domain'
        list dns_search 'lan.home.my.domain'

would accomplish this.. not sure what effect this has if not get passed down via DHCP - where does this variable actually take effect? only on the router itself or something?

You add DHCP configs to /etc/config/dhcp - I'm not sure what config you're trying to add to the network config.

Yea, I think you'll need to add DHCP Option No. 119 - this is added in the DHCP section:

config dhcp 'lan'
        option instance 'lan_dns'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv4 'server'
        list dhcp_option '119,mgmt.home.my.domain,mgmt.home.my.domain' #<---this

This can be done on the LuCI web GUI as well:

3 Likes

You can force the relevant DHCP option if the client does not request it explicitly:

uci add_list dhcp.lan.dhcp_option_force="option:domain-search,lan"
uci commit dhcp
/etc/init.d/dnsmasq restart

Verify like this:

tcpdump -evnni any udp port 67

See also:
https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml

2 Likes

ok thanks for explaining/correcting my misunderstanding.. what does this dns_search option do in network interface section then?

That setting is only relevant for OpenWrt host itself, but not the clients.

1 Like

I honestly don't understand your terminology - are you referring to the DNSMASQ section of the DHCP config?

  • If so, the option domain 'lan' config works for me
  • If not, can you provide a link to the Wiki that instructs you to make such a dns_search config - TBH, I'm not finding any Wiki with such an option
  • [u/]I think you must be referring to the router's PHY config and not the clients DHCP Options[/u] :thinking:

:+1: Yep, @vgaetera confirmed my thinking.

user@machine:~$ nslookup foo
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
Name:   foo.lan
Address: 192.168.1.1

(Obviously, I assigned the hostname foo to my router for this test.)

1 Like

dns_search values seem to appear in /tmp/resolv.conf.d/resolv.conf.auto. At least in some cases (my ISP pushes a search domain).

1 Like

correct.

This doesn't seem clear enough in the wording of that LUCI section (at least to me). I thought this was partly where I could configure how this interface behaves in relation to it's use by other hosts on the network as well (as some of the other settings in that very Advanced Settings tab also affect other clients (like IPv6 hints)..

I feel it would be helpful/clearer if there was a (?) This setting only applies to the router itself and not any clients that connect to it hint below it (like there is under the DNS weight setting below it), then I wouldn't have gone down this wrong path. Unless i'm the only dumb one :slight_smile: Would a PR for this be considered?

You had to navigate into the interface config, then hit advanced. Also note, you missed hitting DHCP Server and the Advanced Settings Field for adding DHCP Options.

Keeping in mind you were attempting to configure DHCP Option No. 119, I'm not sure of what was unclear.

Why would a network setting apply to the clients that connect to it - that doesn't occur with other machines that have that setting, does it?

I do have an idea. Maybe that note can be added to its Wiki description here: https://openwrt.org/docs/guide-user/network/ipv4/configuration#protocol_static_ipv4

You can:

  • Get a Wiki account (there's a thread on how to)
  • Provide the wording, and I or someone else with access could edit it

Since I just located that by navigating to the /etc/config/network page for Interfaces, then navigating to IPv4, and Static Protocol - I honestly don't see the confusion, as it relates to verbiage that would make it more clear. Feel free to provide a sentence or two for the Wiki?

:spiral_notepad: EDIT: BTW, I think you could write that simple change and make your own PR, I can only imagine it's a bit of adding the info icon and HTML small text under the field. I'm sure someone here knows how to find the exact URL to that part of the code on GitHub.

1 Like

i guess i thought some settings here affected the clients, without thinking specifically about the internals of dhcp (from a user-experience perspective, not everyone knows what dhcp-option the 119 one is.. as (without wishing to sound boastful) i wouldn't say i'm the typical user).. then again i did get mislead :slight_smile:

done.

That's exactly what I was suggesting.. I found at least two edits that would need to be made here and here, but i'm not sure if there's any other place that also is relevant?

3 Likes

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