frigidcode

frigidcode

Reliable mDNS with Arch/Manjaro

Looking for some help having my laptop reliably use mDNS to resolve local nerves projects connected over usb. For this example I am using a Raspberry Pi Zero W, System76 Galago Pro, Majaro Linux (consider this the same as Arch), and a new nerves project burned to the sd card.

Packages installed:

  • avahi
  • nss-mdns

Services disabled and stopped:

  • systemd-resolvd

Services enabled and started:

  • avahi-daemon

Relevant line in /etc/nsswitch.conf:

hosts: files mymachines mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns mdns4 myhostname

When I plug the usb cable in I manually edit the connection and switch it to Local-Link Only. The connection is established and the following lines are shown when viewing the status of the avahi-daemon.service:

Mar 08 08:13:26 schmerz avahi-daemon[558]: Withdrawing address record for fe80::1bd2:2363:f3f0:10fa on enp0s20f0u7.
Mar 08 08:13:26 schmerz avahi-daemon[558]: Leaving mDNS multicast group on interface enp0s20f0u7.IPv6 with address fe80::1bd2:2363:f3f0:10fa.
Mar 08 08:13:26 schmerz avahi-daemon[558]: Interface enp0s20f0u7.IPv6 no longer relevant for mDNS.
Mar 08 08:13:26 schmerz avahi-daemon[558]: Joining mDNS multicast group on interface enp0s20f0u7.IPv6 with address fe80::1bd2:2363:f3f0:10fa.
Mar 08 08:13:26 schmerz avahi-daemon[558]: New relevant interface enp0s20f0u7.IPv6 for mDNS.
Mar 08 08:13:26 schmerz avahi-daemon[558]: Registering new address record for fe80::1bd2:2363:f3f0:10fa on enp0s20f0u7.*.
Mar 08 08:13:32 schmerz avahi-daemon[558]: Joining mDNS multicast group on interface enp0s20f0u7.IPv4 with address 169.254.158.42.
Mar 08 08:13:32 schmerz avahi-daemon[558]: New relevant interface enp0s20f0u7.IPv4 for mDNS.

Sometimes I can ping nerves.local and have it resolve, ssh was tested to work as well :slight_smile: However this is not consistent, and I can’t tell why. Any help would be great, I spent an absurd amount of time dealing with this issue across multiple distros. Majaro is the first to actually work at all, so I am hopeful.

Nerves config, stock generated config:

config :nerves_init_gadget,
  ifname: "usb0",
  address_method: :dhcpd,
  mdns_domain: "nerves.local",
  node_name: node_name,
  node_host: :mdns_domain

Thanks!!

Most Liked

fhunleth

fhunleth

Co-author of Nerves

The IP address of the Nerves device will be the same even after reboots. It is computed off the serial number of the Raspberry Pi, so if you have multiple Pi’s connected to your computer, they’ll all have different addresses. Once you have the address, though, you could add it to the hosts file to avoid mDNS altogether.

There might be another problem. I’ve been noticing lately that Raspberry Pi Zeros don’t connect reliably to Linux computers and it’s everything USB. This seems to correlate with a Linux update from GitHub - raspberrypi/linux: Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/ · GitHub, but I don’t understand it. My MacBook Pro does not have this issue at all.

Frank

fhunleth

fhunleth

Co-author of Nerves

There is an issue with the Raspberry Pi Zero’s USB gadget mode being flaky. It’s really hard to determine what the issue is or even hints to provide upstream. I’ve seen some commits to the Raspberry Pi’s Linux github addressing the dwc2 driver (the gadget mode one), but none of them seem to work. I’m tracking their tip 4.19 revision now.

I have a PR that compiles the dwc2 driver as a module instead of building it into the kernel. At the moment, I’m enjoying a long streak of gadget mode working. The tradeoff is that the time for the USB gadget network and serial to come up is longer. I believe that this only changed the timing and things are “working”. Consistently booting is obviously better than booting slowly, so I’m leaning to merging this assuming it continues working.

As for the other issues, if the USB connection isn’t working, then nothing higher level will work. The ModemManager change will fix a bunch of junk characters being sent over the virtual serial port. I’m not sure why the IP address is changing unless you’re getting a link local one. At any rate, I’m hopeful that PR 100 will make things better and then we can get a new system out.

ConnorRigby

ConnorRigby

Nerves Core Team

@frigidcode I second the problem that Frank described. It effects my machine as well (i run Arch btw :stuck_out_tongue:)

A way to test is to do the following:

  1. run dmesg -w in one terminal tab
  2. plug rpi in
  3. observe for messages that look like ...failed to set dts...

If that isn’t the case your avahi daemon conf may be incorrect. I can’t remember where the config file is but i had to make some changes to it on Arch to get reliable mdns.

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement