0

My Pi cannot resolve hostnames of other services in the same local network. Resolution of external services works fine.

$ nslookup example.com
Server:     127.0.0.1
Address:    127.0.0.1#53

Non-authoritative answer:
Name:   example.com
Address: 93.184.216.34
Name:   example.com
Address: 2606:2800:220:1:248:1893:25c8:1946

For example there's a host thesource.local that I connect to from my e.g. MacBook but name resolution from the Pi fails:

$ avahi-browse -a|grep SSH
+   eth0 IPv6 thesource                                     SSH Remote Terminal  local
+   eth0 IPv4 thesource                                     SSH Remote Terminal  local
$ ssh [email protected]
ssh: Could not resolve hostname thesource.local: Name or service not known

This is strictly an issue with local names on the Pi. Connecting from other hosts (e.g. the MacBook) to the Pi using ssh [email protected] works just fine (thanks to Bonjour/Avahi I guess).

My /etc/dhcpcd.conf looks like so as I need a static IP address:

interface eth0
static ip_address=192.168.0.10/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 9.9.9.9 2620:fe::fe

For the sake of completeness here's the (abbreviated) ipconfig output:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.10  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::8aa2:f238:cae7:82f3  prefixlen 64  scopeid 0x20<link>
        ether dc:a6:32:0f:cd:a4  txqueuelen 1000  (Ethernet)

Update 2020-03-29

More information asked for in the comments:

$ grep -v "#" /etc/avahi/avahi-daemon.conf|grep -v "\["

use-ipv4=yes
use-ipv6=yes
ratelimit-interval-usec=1000000
ratelimit-burst=1000

enable-wide-area=yes

publish-hinfo=no
publish-workstation=no

$ service avahi-daemon status
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
   Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-03-28 19:46:11 CET; 17h ago
 Main PID: 329 (avahi-daemon)
   Status: "avahi-daemon 0.7 starting up."
    Tasks: 2 (limit: 4616)
   Memory: 1.2M
   CGroup: /system.slice/avahi-daemon.service
           ├─329 avahi-daemon: running [white-rose.local]
           └─340 avahi-daemon: chroot helper
12
  • Can you ping the IP address of thesource.local from the Pi and the Mac?
    – user115418
    Commented Mar 28, 2020 at 13:10
  • Yes, connectivity is ok but name resolution not. I can ping and telnet into thesource.local. Commented Mar 28, 2020 at 13:57
  • On the Mac, can you ssh [email protected] fine?
    – user115418
    Commented Mar 28, 2020 at 15:08
  • Have you tried this sans .local? avahi-browse obviously finds thesource... If so this may be a matter of that getting appended on the Mac.
    – goldilocks
    Commented Mar 28, 2020 at 15:13
  • Yes, I had already tried w/o .local. The local "domain" is also listed in the last column of the Avahi browser output. However, you make me think that it would probably be more reasonable to expect thesource to work rather than thesource.local. That latter is the mDNS/Bonjour/ZeroConf name that SSH/ICMP/etc. on the Pi probably are not aware of? Commented Mar 28, 2020 at 15:38

1 Answer 1

1

I ran into the same issue when I did a clean buster install on a new sd card. It took a bit of digging, but found the readme.md in the nss-mDns GitHub repository wants to include mdns4 on the hosts line of /etc/nsswitch.conf:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

Since other hosts on the network could resolve the new Pi, <f>.local, I assumed it's mDns was properly broadcasting. In my case, running avahi-resolve -n <g>.local on <f> would find the address, but ping <g>.local would not; so it pointed me to how names were resolving.

It was hard to find because my working pi, <b>.local and the old image on the sd card I swapped out <g>.local didn't have that in nsswitch.conf. But, <b> is running Jessie; and I think <g> is running Stretch(?).

1
  • You did not installed a clean buster image, or you modified it. The line in /etc/nsswitch.conf is given by default on an unmodified Raspberry Pi OS image. It is set with installed libnss-mdns.
    – Ingo
    Commented Oct 24, 2020 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.