Local DNS: mDNS (.local) vs .lan vs standalone hostnames

Hello,

I’ve a couple routers running OpenWrt is it is all fine but I never quite understood the local domain resolution implementation. My main router is running SmartDNS as main DNS server and set to read dnsmasq entries.

Consider this results:

$ dig nas.local "@172.21.1.1" +short

$ dig nas.lan "@172.21.1.1" +short

$ dig nas "@172.21.1.1" +short
172.21.1.100

Now my questions:

1. Although dnsmasq has lan set as the network domain, I can’t really resolve anything .lan´ as seen above.

config dnsmasq
        option domainneeded '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option cachesize '1000'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option localservice '1'
        option ednspacket_max '1232'
        option port '0'

Meanwhile the lease file doesn't appear to have any .lan suffixes, and maybe that explains why the resolution doesn't work:

$ cat /tmp/dhcp.leases
1762980412 xx:xx:xx:xx:xx:xx 172.21.1.6 Phone yy:yy:yy:yy:yy:yy:yy
1762980270 xx:xx:xx:xx:xx:xx 172.21.1.12 PC
(...)

2. Shouldn't we have have overlapping entries to cover the mDNS space? Doing mDNS via the standard mans is slow (usually a few seconds to get an IP), why can't the router's DNS server also answer with IPs it knows for .local to speed things up?

My SmartDNS config:

 cat /etc/config/smartdns

config smartdns
        option enabled '1'
        option server_name 'xxxx.yyy.ccc'
        option port '53'
        option auto_set_dnsmasq '1'
        option tcp_server '0'
        option ipv6_server '1'
        option bind_device '0'
        option dualstack_ip_selection '1'
        option serve_expired '1'
        option cache_persist '0'
        option resolve_local_hostnames '1'
        option force_https_soa '0'
        option rr_ttl_min '600'
        option seconddns_port '6553'
        option seconddns_tcp_server '1'
        option old_port '53'
        option old_enabled '1'
        option old_auto_set_dnsmasq '1'

Trying to access stuff on the network anything any prefix like nas usually ends up on a web search and .local via mDNS is slow.

Thank you.

Change the smartdns listening port to something else (5353 for example).

Then in the dnsmasq configuration file

should be replaced with

list server '127.0.0.1#5353'
option noresolv '1'

and the .lan resolution should start working.

Sure, but that means dnsmasq will take over as the main DNS resolver and will run requests to SmartDNS for all domains it doesn't know. Although it is a valid approach and will work it also means way slower DNS resolution.

It doesn't seem correct that OpenWrt offers even a GUI option to make SmartDNS the first and only resolver with another option to make it read dnsmasq entries but then the lan domain isn't taken into consideration. :S

Thanks for the reply.

Try https://github.com/pymumu/smartdns/issues/1973#issuecomment-2852206004

Smartdns in the current stable release is quite old. I tried installing the latest smartdns release from github but it didn't go well. So now I'm back to dnsmask and I'm not sure I notice any difference

You could make dnsmasq listen on port 5353 and set smartdns to forward only requests for the lan TLD to 127.0.0.1:5353.

#/etc/config/smartdns
...

config domain-rule
        option server_group 'lan'

config server
        option enabled '1'
        option name 'lan'
        option ip '127.0.0.1'
        option port '5353'
        option type 'udp'
        option server_group 'lan'
        option exclude_default_group '1'
#/etc/smartdns/domain-forwarding.list

lan
1 Like

@gechu @pavelgl that does work, but the SmartDNS implementation is wrong nevertheless. Since it has the option to read the lease file it should also do it properly.

Thanks for the help guys.

Did you try to explicitly specify the lease file?

And/or upgrading smartdns?

EDIT: I ran into issues initially became Windows automatically suffixed unqualified domains (eg nodered) with “.lan” which dnsmask could handle but not directly by smartdns.

It's analog to resolve conf on Linux
See the "search" at https://man7.org/linux/man-pages/man5/resolv.conf.5.html

with this setting you disable DNS functionality, it can still work as DHCP or TFTP.

Yes, because I want to use SmartDNS for resolution instead of Dnsmasq - and that's okay.

The problem here is that even though SmartDNS is then set to read Dnsmasq dhcp leases file the resolution of .lan doesn't work. Here:

image

root@router:~# cat /var/etc/smartdns/smartdns.conf
server-name ....
serve-expired yes
dnsmasq-lease-file /tmp/dhcp.leases   <---- should resolve anything in there .lan
rr-ttl-min 600
log-size 64K
log-num 1
log-level error
cache-persist no
resolv-file /tmp/resolv.conf.d/resolv.conf.auto
bind [::]:53
server-tls 1.1.1.1:853  -tls-host-verify cloudflare-dns.com
(...)

there is an issue https://github.com/pymumu/smartdns/issues/1973 might describe a resolution for you. but why not use dnsmasq as upstream dns for .lan instead of parsing dhcp.leases (which seems to not working)?

Yes.

Setup dnsmasq for DHCP and DNS for .lan.

You can for instance set another port for dnsmasq then 53.
Then smart DNS should be configured to forward /lan/ to the dnsmasq instance.

I came to the conclusion that this mess and type of problem is already solved by SmartDNS with two dfiferent options:

mdns-lookup yes
local-domain lan

Info here: https://pymumu.github.io/smartdns/en/config/resolv-dnsmasq-lease/#using-mdns-lookup

BUT this will not currently work in most Openwrt setups because the SmartDNS version used is old. Once those options are available in conjunction with the existing dnsmasq-lease-file one it should all work out without having to set dnsmasq as upstream.

Did you considered building it on your own?
You can even try to just bump the version of that DNS Server on the OpenWrt 24.10 branch.
But yes the long term maintenance might not get easier through that.

I was just upgrading to snapshot right now to check if those options work there. There was some not so distant PR to update smartdns after v24.

You can check the version of the packages without flashing OpenWrt. The wiki links to the package info site and on github OpenWrt packages you will find the makefiles

Edit ps. The OpenWrt package makefile on 24.10 https://github.com/openwrt/packages/blob/openwrt-24.10/net/smartdns/Makefile

Have you tried to just build the package directly from upstream? https://github.com/pymumu/smartdns/blob/master/package/openwrt/Makefile

Yes I can, but since I was running 23.x it was just better to move to snapshot. Eventually I had to go back to 24.x because IPv6 on the WAN seems to be broken on the snapshot but either way the version on the snapshot isn't new enough yet to support those options properly.

Meanwhile in Openwrt 24.10.4 smartdns is 1.2023.43. mdns-lookup was only added in 45 and local-domain I've not no ideia but it doesn't work.

Thanks for the tips.

That's why I asked if you have tried to compile it on your own. So you have not yet.

No, not really. Since I never did it before I'll investigate in on the weekend.