Ping devices on the local network via hostname


I’m trying to reach devices on the local network on which the resin device (Raspberry PI 3) is running by using its hostname, i.e. “DeviceName.local”.

If I ping the device via its IP address, it can be reached, however using the hostname does not work. Using “hostname.${dns-suffix}” where dns-suffix is the suffix specified by the router (which would change whenever the router is changed), works as well.

Is it possible to access devices via hostname in the local network from inside the container? The IP addresses of these devices might change.

Hi, as much as I understand, even on the local network you cannot ping a device just by the hostname, if your local machine doesn’t know what IP address that hostname corresponds to. The router-provided DNS suffix, and the avahi-provided .local helps to bridge that, because the device that pings knows who to ask what the IP is…

Under normal circumstances for example the hostname -d command can be used to discover the current dns suffix, but that doesn’t seem to have access to that information inside docker by default. Also, the /etc/resolv.conf file can (probably should?) contain the dns suffix for example as a line as search $(dns-suffix). I think that information might not be set up in the resin case completely…

This is definitely a legitimate use case, and will ask the team for further information…

Possible yes, I have this working on my network after installing libnss-mdns on my rpi.

sudo apt-get install libnss-mdns

Can you share how you did this? I followed this tutorial and don’t see other hosts when I do getent hosts

I added avahi (based on this example) and can now view some of my devices at their .local hostname. I can’t find my philips-hue even though I have another raspberry pi running raspbian on the same network where I can do API calls to the philips-hue hostname. Any ideas on this?

I should have mentioned I was running raspbian:latest which I believe either includes avahi-daemon or is installed as a dependancy of libnss-mdns.

Could I just check the status of this? Does the advice provided by swgn resolve issues, or is there still a problem?

Communication to local devices using their hostname certainly doesn’t work on Resin out of the box. I couldn’t get it to work with only the information that swgn provided. I’d love a standalone example of this that could be used to show what’s required to make it work.

Edit: Here’s the code that I tried, but didn’t work. (This commit is when I removed it)

Hey @dillon1337,

So you are trying to ping other devices in the network by hostname? I forked our avahi example to use the avahi daemon in the host.

I can then see all devices on the network by running:

avahi-browse -a

I’ve also tested and pinging the hostnames listed from the avahi output seems to work.

Let me know if that helps you out @dillon1337

I appreciate you sharing that example. I put everything important from that example in my project but avahi-browse -a does not list the device (it doesn’t list that device on my mac for avahi-browse either BTW). I’m trying to communicate with a philips hue gateway. On my mac (on the same network), I can do ping philips-hue and I get a response:

PING philips-hue.home ( 56 data bytes
64 bytes from icmp_seq=0 ttl=255 time=4.211 ms

On the resin device, if I do the same ping philips-hue (after installing iputils-ping), I get: ping: unknown host philips-hue.

Clearly I don’t understand the networking side of this issue in detail, but if the mac can resolve the hostname, I would assume that I could do the same in resin. Do you have any other ideas of how I can do this? Thanks for the help so far.

I think the issue is, that the router sets the .home for the local network’s domain name. Thus avahi (and avahi config, probably both on your Mac and on resinOS) is looking for it’s default .local ending. Check /etc/avahi/avahi-daemon.conf and the domain-name= setting (the default is domain-name=local). I think this is the missing piece, but hard to check not being on your own network.

That domain name is broadcast by the router as well, though, so a normal ping should be able to resolve philips-hue to philips-hue.home, possibly, but not sure… Maybe this info is something that can further your investigation?

I changed the line in /etc/avahi/avahi-daemon.conf to read domain-name=home but I still can’t ping it by hostname.

Can you ping any local devices on your network by hostname? I found that the iPhone app Fing is good for discovering hostnames on the network. No matter which device I try, I always receive unknown host.

After researching this some more, I don’t think avahi is really going to solve my problem. As mentioned in the second post in this series, I think I actually want to change resolv.conf. On my mac, my /etc/resolv.conf lists

domain home

which explains how it can resolve the hostname. I don’t think it’s using avahi/bonjour.

The docker docs explain how to setup DNS. It doesn’t look like these options are available on resin.

It also looks like docker doesn’t allow for something like this to work: RUN echo "domain home" >> /etc/resolv.conf

Do you have any suggestions on how to make resolv.conf work for me on resin?

Hey @dillon1337 did this work for you?

No, in my situation I don’t think avahi will work. In my last post, I asked about resolv.conf, which might be the way forward, but I need some help from Resin.

Hi! Any updates here? We have the same issue in our company network. The resin host got 2 DNS servers via DHCP plus one ?preconfigured? in ResinOS with IP So 3 DNS servers in total. Sometimes the resolution of our internal names fail. How can we permanently edit the resolv.conf or get rid of the


you can set up the dns IPs using the NetworkManager configuration. You can see some examples here:

Is this helpful?

Hi Ilias,
thanks for your fast response. I already read the network section in the documentation and tried to configure the DNS via dbus. Modifying the image is only plan B.

on the host you see:

bash-4.3# cat /etc/resolv.dnsmasq
search domain2.internal
nameserver XX.XX.XX.XX
nameserver YY.YY.YY.YY

Where did the come from. We only have the XX and YY in our DHCP setup.

Thanks in advance,

I’m guessing Resin automatically adds Google’s DNS, but we will need clarification from them. Surprisingly, my file only lists nameserver, which I didn’t add either… Seems to be a Docker feature.

Would you mind sharing your script that adds the nameservers to resolv.conf? I see there’s an example on the networking page, but it doesn’t seem to cover the DNS specifically.

Hello again,
so I was informed that you can configure the behavior of resinOS by setting the “dnsServers” property in the config.json file in the boot partition. So you will need to add "dnsServers": "XX.XX.XX.XX YY.YY.YY.YY" (space separated) in the config.json.

You can read more about reading and writing the config.json file here: