pidd wrote: ↑Sat Jul 18, 2020 1:09 pm
I am trying to figure out why my PC chooses MDNS for names without decimal points whereas the Pis go for DNS. If the Pi's did an MDNS request then I'd be able to address them by name again.
It certainly does perform an mDNS request, which fails (esp. if you disable multicast...) and then DNS is tried.
When presented with a "dotless" name, the resolver will append what's specified by keywords "domain" or "search" in /etc/resolv.conf, and start querying. But it doesn't stop there, and it also queries available servers for the name alone.
Looks a bit dubious to me but I suppose the rationale is that the query is received by a local DNS server/cache, which will do the right thing. Note that systemd-resolved by default would
not forward names without any domain part. There is an option to revert to forwarding...
Anyways, on raspios, if you want to avoid sending a query to DNS servers for a non existing host/domain "foobar", the following works for me.
First the situation before the fix
Code: Select all
root@pi:~# cat /etc/resolv.conf
# Generated by resolvconf
domain dyn.domain
search domain dyn.domain
nameserver 172.17.0.2
root@pi:~# tcpdump -n -i any udp port 53 &
root@pi:~# getent hosts foobar
18:36:29.639703 IP 172.17.255.230.52816 > 172.17.0.2.53: 13279+ AAAA? foobar.domain. (31)
18:36:29.641083 IP 172.17.0.2.53 > 172.17.255.230.52816: 13279 NXDomain* 0/1/0 (95)
18:36:29.641360 IP 172.17.255.230.58432 > 172.17.0.2.53: 58325+ AAAA? foobar.dyn.domain. (35)
18:36:29.641727 IP 172.17.0.2.53 > 172.17.255.230.58432: 58325 NXDomain 0/0/0 (35)
18:36:29.641898 IP 172.17.255.230.39363 > 172.17.0.2.53: 7382+ AAAA? foobar. (24)
18:36:29.642266 IP 172.17.0.2.53 > 172.17.255.230.39363: 7382 0/0/0 (24)
See the third query for "foobar." as a top-level domain name?
So,
Code: Select all
root@pi:~# man resolv.conf
root@pi:~# man resolvconf.conf
root@pi:~# nano /etc/resolvconf.conf
Added to the end of the file:
Code: Select all
# No DNS query for names without domain
resolv_conf_options=no-tld-query
and rebooted.
Same test, with option no-tld-query now present in resolv.conf:
Code: Select all
root@pi:~# cat /etc/resolv.conf
# Generated by resolvconf
domain dyn.domain
search domain dyn.domain
nameserver 172.17.0.2
options no-tld-query
root@pi:~# tcpdump -n -i any udp port 53 &
root@pi:~# getent hosts foobar
18:56:01.749397 IP 172.17.255.230.58238 > 172.17.0.2.53: 38623+ AAAA? foobar.domain. (31)
18:56:01.750974 IP 172.17.0.2.53 > 172.17.255.230.58238: 38623 NXDomain* 0/1/0 (95)
18:56:01.751257 IP 172.17.255.230.37884 > 172.17.0.2.53: 10183+ AAAA? foobar.dyn.domain. (35)
18:56:01.751618 IP 172.17.0.2.53 > 172.17.255.230.37884: 10183 NXDomain 0/0/0 (35)
2 domains specified by option search, 2 queries. All good now.