1

I have a Raspberry Pi machine on a wired connection to my local router. My router connection monitoring utility indicates that the device is connected to the local network and visible to the other devices on the network under the device name / hostname raspberrypi0, at the private IP address 192.168.1.2:

enter image description here

ping 192.168.1.2 succeeds with no packets lost, and the device is reachable (and SSH-able) from that address. However, neither ping nor nslookup can resolve the actual hostname that the router purports it is broadcasting (this is on macOS, hence the .local at the end):

$ ping raspberrypi0.local
ping: cannot resolve raspberrypi0.local: Unknown host

$ nslookup 192.168.1.2
Server:     192.168.1.1
Address:    192.168.1.1#53

*** Can't find 2.1.168.192.in-addr.arpa.: No answer

My network router at 192.168.1.1 is the only DNS server the machine is working with:

enter image description here

So then why is this device not reachable via its hostname?

2

There are several different (incompatible) ways of discovering names for hosts. When you use a .local name on macOS (and other OSes that support it), you're doing a local query over the multicast DNS (mDNS) protocol. This can only discover other hosts that support (and advertise over) mDNS; on Linux (including Raspbian), this is generally provided by Avahi.

As far as I know, Avahi is installed and running by default in Raspbian (or maybe just in the full install?). You can check with ps -ax | grep [a]vahi-daemon. If it's not, you may need to install and/or set it up.

Note: nslookup doesn't do mDNS, just regular DNS. The same goes for dig and host. ping, on the other hand, uses the OSes resolver, so it'll use mDNS if the system is set up to use it.

I'm not sure what the listing on your router monitor is using to attach the name "RASPBERRYPI0" to your Pi, but my guess would be that it's the name the Pi sent in with its DHCP request when it first connected to the network (essentially, "Hi, I'm RASPBERRYPI0, can someone give me an IP address and settings to use on your network?"). The router/DHCP server probably records this in its lease table ("I handed out the address 192.168.1.2 to something named RASPBERRYPI0"), and displays it when you look up clients. But the DHCP request is only relevant to the DHCP server, and the lease table isn't available to anything else on the network, so just because the router knows its name doesn't necessarily help any other hosts find it.

Well, except that some routers also serve DNS for the local network, and some use the names in the lease table to populate some sort of local DNS names. But your Mac is using the local router (192.168.1.1) as its DNS server, and looking up 192.168.1.2 didn't get anything back, so your router probably doesn't do this.

There are still other ways to find local computers by name, like NetBIOS name service; if other computers on the local net are finding the Pi, they might be using that. Or possibly something else, it's hard to say.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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