I have a Mac connected to my own router, which is connected to the router/modem from my ISP, with the following configurations:

ISP router/modem configuration

Own router configuration

Mac connects to router using DHCP.
Mac DNS is set to

On my own router, I can see a number of connected devices:


I can ssh to by IP, but if I try by hostname, it's not recognized:

ssh: Could not resolve hostname rpi-node-4: nodename nor servname provided, or not known

Since the router is aware of hostnames, and the Mac is told to use (the router) as DNS, I expected the Mac to be able to resolve the hostnames, but it doesn't work.

Note that I don't want to manually edit the /etc/hosts file on the Mac (because I have multiple machines, and because I use dynamic IPs, so I don't want to have to update 3-4 hosts files everytime IPs are re-allocated).

Can someone please tell me where did I mess up?

  • I doubt the router actually resolves local hostnames to IP addresses. It is just a forwarder - it forwards requests to your ISP. You can always use nslookup and query the router directly. That will answer the question once and for all. – Appleoddity Oct 12 '17 at 0:48
  • How can I query the router directly ? I tried a bunch of things with nslookup, but it didn't seem to work. Thanks. – ccc Oct 12 '17 at 22:52

Your router probably only knows those RPi's names because those are the names they used when making DHCP requests, and your router is probably your network's DHCP server.

Some home gateway routers have the ability for you to enter hostnames for each LAN private IP address, and the router will act as a DNS content server instead of just a DNS relay. See if yours has that feature, and set it up if it does.

If it doesn't have that feature, you could use mDNS and DNS-SD (a.k.a. IETF ZeroConf, Apple Bonjour) to establish a .local domain so you can connect to your RPi's by name. I believe Raspbian doesn't tend to have an mDNS implementation enabled by default, so you might need to do something like sudo apt-get install avahi-daemon to get Avahi, which is a popular open source mDNS implementation.

  • Router is Netgear Nighthawk AC1900 (R7000), the OS on the PIs is hypriot. I can enter hostnames on the router for each IP, but that means I lose the ability to use DHCP, I have to use fixed IPs, which I wanted to avoid. I suppose that leaves mDNS as the only option. Could you please give me some more resources/details/links on how to install and configure it ? Thank you. – ccc Oct 12 '17 at 22:43

Your search domain may have been missed when setting up your router DHCP settings. Now your Mac computer doesn't know where to look for local hostnames to IP's.

To fix this:

  1. Go to System Preferences -> Network
  2. Select your active network adapter from the left column
  3. Click Advanced at the bottom right hand corner
  4. Select the DNS tab at the top
  5. Enter your search domain under search domains (Mine is attlocal.net because I use AT&T. You may have to do a search to find yours)
  6. Click Apply. You should now be able to access {hostname}.local

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.