Can't see `nerves.local` on network anymore

(This is ported from an unrelated GitHub issue that I didn’t want to clog up)

I currently have a device that is just wlan0 network setup and have suddenly lost the ability to get to it via nerves.local (although IP address still works fine)

At first it would just last a few minutes but then I could connect as normal. Now I’m a week in and still can’t see nerves.local on my network from MacOS. Although not sure if that is network setup or my configuration…

Portion of my current config

config :nerves_init_gadget,
  ifname: "wlan0",
  address_method: :dhcp,
  node_host: :mdns_domain,
  ssh_console_port: 22

  [ssid, psk] =!(".wlan_settings") |> String.split()

config :nerves_network, :default,
  wlan0: [
    ssid: ssid,
    psk: psk,
    key_mgmt: :"WPA-PSK"

case Mix.env do
  :dev ->
    config :nerves_init_gadget,
      mdns_domain: "nerves-dev.local",
      node_name: "nerves-dev"

  :prod ->
    config :nerves_init_gadget,
      mdns_domain: "nerves.local",
      node_name: "nerves"
1 Like

I think there have been known issues with MacOS and mdns. I don’t run OSX, so i’m not really sure how to help, but on linux i need to restart avahi-daemon (the program responsible for mdns resolution) between network disconnects.

If you ping nerves.local, does it resolve to an IP that isn’t the same as your device, or does it say it can’t find the host nerves.local?

Initial response from @fhunleth in GitHub…

@jjcarstens Since you can ping the device, I assume that it’s using DHCP to get an address and not link local. This particular issue deals with link local addressing. If you have any uncertainty, check your config.exs that both nerves_init_gadget and nerves_network are being told to use DHCP or post here.

My second guess is that multicast is being filtered on your wireless LAN. Some access points do this, but they’re usually corporate ones. To see if that’s the problem, could you try running Wireshark on your Mac and look for mDNS requests and responses? If you can log into your Nerves device, you can also run RingLogger.attach . The mDNS client that we use is pretty noisy, so you should see the requests there as well.

Thanks for the suggestions @fhunleth. I checked my nerves_init_gadget and it sets address_method: :dhcp. nerves_network looks okay too. I wouldn’t except those to be the problem because for the first week or so running this I had no problem using nerves.local on mdns (and configs haven’t changed).

Did your second suggestion and RingLonger isn’t even logging thing from mDNS. Wireshark kind of confirms because all I see are mDNS requests from my machine and nothing back from my rpi3.

Device logs do show that this though which looks peculiar (seems like domain should not be empty):

12:00:22.666 [info]  DHCPManager(wlan0) udhcpc {Nerves.Udhcpc, :renew, %{domain: "", ifname: "wlan0", ipv4_address: "", ipv4_broadcast: "", ipv4_gateway: "", ipv4_subnet_mask: "", nameservers: [""]}}

The other thing to note is that my network is an AirPort Extreme and the devies IP is a DHCP reservation mapped to its Mac address (not sure if that will matter)

Have to stop for now, but will start investigating more a little later tonight

It says it cannot resolve the host. (Should have put that in there)

Sorry, there are also 2 other posts missing from this. Apparently they have to be approved by a moderator…

This does seem to be a router/switch problem. Getting mdns and the .local domain can be tricky on a local LAN if the router filters it out of the box, especially when WiFi is involved.

If you are assigning it a reserved IP address then you might get better results just adding a hostname/IP for it to your /etc/hosts file. I’m not sure if that’s a helpful solution for you or not.

1 Like

Thanks @tmecklem

I think you’re right it’s a router/switch problem. Using /etc/hosts worked like a charm and would be a great way to resolve this.

But, I wanted to go further (just for knowledges sake). Here’s what I ended up doing that seemed to get it all in a working state again:

  1. sudo killall -HUP mDNSResponder on MacOS machine to reset DNS cache and put mDNS daemon in clean state
  2. Restarted my router
  3. Restarted nerves device (rpi3) via unplug <-> plug
  4. Performed a victory dance :tada::man_dancing:

I was hoping to be able to find more specific details for root cause and fixes, but decided this and utilizing /etc/hosts file was good enough in my case.