3

I am using Ubuntu 22.04. I want to be able to resolve hostname of a device connected to my local network. The device is publishing its hostname using mDNS. On my machine, I am able to ping device.local, but nslookup returns:

** server can't find device.local: NXDOMAIN

avahi-resolve also return proper address.

In nsswitch.conf I have:

hosts:          files mdns4_minimal [NOTFOUND=return] 

Note that the device has static IP address. The device.local is not know to my DNS server and I want to keep that in this way.

I tried various modification of nsswitch.conf and dnsmasq config modifications. I was expecting nslookup to be able to resolve address of the device but without results.

Adding entry in /etc/hosts works but I don't like this solution as address of the device could change in the future.

Giacomo1968
  • 58,727

1 Answers1

9

nslookup is specifically a troubleshooting tool for regular (non-multicast) DNS only. It deliberately ignores /etc/nsswitch.conf and contacts the first DNS server listed in /etc/resolv.conf unless you explicitly specify some other DNS server to query.

avahi-resolve is a similarly dedicated tool for mDNS: it will always use mDNS only.

Instead, use e.g. getent hosts device.local or getent ahosts device.local. Those commands will use the hostname resolution methods configured in /etc/nsswitch.conf, doing exactly what most actual applications do when resolving hostnames.

telcoM
  • 5,167