openwrt / packages

Community maintained packages for OpenWrt. Documentation for submitting pull requests is in CONTRIBUTING.md
GNU General Public License v2.0
4.01k stars 3.49k forks source link

unbound: static leases are not used extra DNS entries #22593

Closed jcassette closed 1 year ago

jcassette commented 1 year ago

Maintainer: @EricLuehrsen Environment: OpenWrt 23.05.0 r23497-6637af95aa / LuCI openwrt-23.05 branch git-23.236.53405-fc638c8

Description:

When Unbound "Extra DNS" UCI option is set to "Host Records" or "Host/MX/SRV RR" or "Host/MX/SRV/CNAME RR", the hostnames of static leases are not used as extra DNS entries.

This is not in accordance with the description of the DHCP Hostname option:

Hostnames are used to bind a domain name to an IP address. This setting is redundant for hostnames already configured with static leases, but it can be useful to rebind an FQDN.

Reproduction steps:

uci add dhcp host
uci set dhcp.@host[-1].name='example'
uci set dhcp.@host[-1].dns='1'
uci set dhcp.@host[-1].mac='00:01:02:03:04:05'
uci set dhcp.@host[-1].ip='10.1.1.111'
uci commit dhcp

uci set unbound.ub_main.add_extra_dns='3'
uci commit unbound

/etc/init.d/unbound restart

Actual behavior:

root@OpenWrt:~# nslookup example.lan
Server:         127.0.0.1
Address:        127.0.0.1:53

** server can't find example.lan: NXDOMAIN

** server can't find example.lan: NXDOMAIN

Expected behavior:

root@OpenWrt:~# nslookup example.lan
Server:         127.0.0.1
Address:        127.0.0.1:53

Name:   example.lan
Address: 10.1.1.111
EricLuehrsen commented 1 year ago

The question is do you want DNS when the device is not connected? DNS is pulled from the DHCP lease file.

jcassette commented 1 year ago

That's the behavior of dnsmasq when the dns option is set

See https://github.com/openwrt/openwrt/blob/ae500e62e2938e112ae1fc6aa7389e8c7b784b13/package/network/services/dnsmasq/files/dnsmasq.init#L354-L357

        config_get_bool dns "$cfg" dns 0
        [ "$dns" = "1" ] && [ -n "$ip" ] && [ -n "$name" ] && {
                echo "$ip $name${DOMAIN:+.$DOMAIN}" >> $HOSTFILE_TMP
        }