Connecting to device (using hostname) via WIFI

I have a local-mode enabled device (raspberrypi 4). It is connected with an ethernet cable and I am able to connect to it using the hostname (testdevice.local) with other ‘wired’ devices.

However when I try to connect to it from wireless devices over WIFI the hostname does not get resolved. Accessing the device via ip-address does work.

I think it’s a pretty normal usecase where my device is connected via ethernet-cable and other wireless devices are trying to connect to it using the hostname, isn’t it?

Also I kinda just figured out the avahi discovery service is just for developer purposes.
Is it possible to enable it on production-images aswell? I’d like my device to be easily found with a hostname in production environements.

Hi, could you please log into the hostOS in your device using the dashboard and paste the result of the following command:

route

This will print the kernel routing table and will allow us to understand the specific network configuration on your device. It is possible that you have configured two network interfaces in the same subnet so DNS messages are being forwarded through the first routing table match.

Regarding your second question, avahi is running also on production devices. You can check this by running avahi-browse --all from a Linux PC and seeing that the SSH service is being broadcasted.
However, note that balena scan won’t show local devices on a production build as this is used for local development mode.

I am using Open Balena btw so no dashboard for me.

The output from route:

I have checked and wireless or wired both assign the same subnetmask-range to my laptop.

hey there!
It looks like an issue with mDNS and resolving the hostname from your host device Can you please confirm the following:

  1. What operating system your host computer is using?
  2. If you have 2.4 and 5GHz networks, make sure that the host computer and the device are on the same one?

Thanks

I am not sure what you mean with ‘host computer’.

My device is connected to my network via ethernet, so no 2.4 or 5GHz involved.
I have a container running a simple website running on port 80.

Surfing to the hostname on wired devices results in showing the website.
Wireless devices (e.g. phones, laptops, tablets) won’t show the website. However they DO show the website when I use the ip-address of the balena-device in the browser.

Hi, in this instance “host computer” refers to the computer you are trying to access the device from. It sounds like your router is possibly using a different DHCP configuration for the wired and wireless networks. Can you use a tool like dig to check that the DNS servers used for wired and wireless connections are the same?
It should be as simple as running dig testdevice.local from your laptop using a wired and wireless connections and comparing the results.

I don’t really see a useful difference:

Red being the wired connection and green the wireless.

I am on a windows 10 machine btw and executing commands using WSL (unbuntu).

Which Windows OS build do you have? Do you have an mDNS responder installed on your maching (like Apple’s Bonjour)?

I do have bonjour installed yes.

One more question, what other devices have you tested the wired connection on?

Two android phones. A Oneplus 6 and a Samsung Galaxy S9.

Forgive my stupidity but I don’t see how my laptop / host OS is relevant. Maybe it’s because I explained my issue the wrong way?

What I am trying to achieve is to place a device into any given network. I want that device to be ‘found’ inside that given network using a hostname, in my case ‘shipr.local’. Users will be able to download an app on their phone (IOS or Android) and that app will connect to the device. I don’t want to worry about ip-addresses inside my android/ios-code. Each user will have different ip-addresses and subnet-ranges; I just want to use the ‘shipr.local’ hostname to communicate to my api (which the device will expose).

The reason I think my host OS is irrelevant is because the hostname-resolving (which is probably done by mDns? I don’t know I am a noob in that case) should work on any device; windows, linux, android or IOS. Although in reality I would only care about android or IOS. Also having bonjour installed or anything shouldnt be a prerequisite for this to work.

Right now I am testing this process using a windows laptop (it’s just my development laptop). I can reach my device via my browser via ‘http://shipr.local’. But only in a wired situation, as soon as I use my WIFI the browser responds with a 404. It does however show my website when I browse to my ip-address.

.local domains work differently than normal ones, and it relies on a different protocol called mDNS. There are some differences with plain DNS. For example, you don’t need to pay for .local domains and there is no central registry for those domains. Unfortunately, support for mDNS domains is not included by default in most non-Linux installations. Because of that, an mDNS resolver like bonjour is required to get .local domains working. More info here: https://en.wikipedia.org/wiki/Multicast_DNS

mDNS relies on multicast packets. What might be happening is that the router is not transmitting multicast messages between wired/wireless interfaces, or maybe it’s blocking wireless multicast. Could you fill which of the following combinations work/doesn’t work (host being the device you access):

wired device <-> wired host
wireless device <-> wired host
wired device <-> wireless host
wireless device <-> wireless host

Ok, will do that. Before I can provide that list something else is blocking me. But I will create another topic for that.