0

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 192.168.1.1 using DHCP.
Mac DNS is set to 192.168.1.1

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

rpi-node-4 192.168.1.4
rpi-node-1 192.168.1.5

I can ssh to 192.168.1.4 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 192.168.1.1 (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
0

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 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.