4

I can get the Pi Zero on my Mac's network nicely, using the USB OTG mode. It appears as RNDIS/Ethernet Gadget in the Network preference pane, but annoyingly, each time the Pi reappears after rebooting, it's a new RNDIS/Ethernet Gadget device.

It doesn't take long for the list of interfaces to grow and grow, I must have deleted a hundred or more instances of various numbered RNDIS/Ethernet Gadgets.

I'd really like a Pi to come back as the same device each time.

What is causing this, and is there anything to be done about it?

5
  • it's your mac that is causing the issue
    – jsotola
    Sep 19, 2019 at 19:09
  • @jsotola Can you elaborate? Sep 19, 2019 at 23:08
  • the problem is not with the Radpberry Pi, the problem is with the Mac assigning new device names ... delete your post and create a new one here ... unix.stackexchange.com/questions
    – jsotola
    Sep 20, 2019 at 0:29
  • 1
    I'm not going to delete the question, many people use the Raspberry Pis with Macintosh systems like this, and it's likely to help someone else in future. It also doesn't look anything like a general Unix issue. Sep 20, 2019 at 11:23
  • Thank you for not deleting this post: this was exactly the problem I was seeing (and in my case, it had nothing to do with it connecting to a Mac). Nov 29, 2019 at 9:15

2 Answers 2

4

The issue turns out to be that the Raspberry PI's RNDIS module generates a pair of random MAC addresses for the network each time it starts up.

The host therefore sees a new device attached to its network each time, hence the issue described in the question.

The solution is to set the MAC addresses on the PI rather than allowing them to be set.

The addresses are:

  • host_addr, which is what will be seen by the OTG host
  • dev_addr, the address seen by the OTG device, in this case the Pi

Assuming that you have RNDIS running on the Pi, create a file at: /etc/modprobe.d/rndis.conf. In it, add:

options g_ether host_addr=ae:ad:f5:9d:9f:ba dev_addr=7a:26:9f:3e:97:6c

After this, on every subsequent reboot, the Pi will always appear as ae:ad:f5:9d:9f:ba to your machine.

You can use a random MAC address generator to produce valid MAC addresses for you.

0

Just a note.

I implemented the methods discussed in the previous question but still found the link setup was intermittent. I found that a working link could be setup by removing/reloading the g_ether module. So it seemed that there is some delay needed to properly create the USB network link.

The only way that seems to work consistently for me was to remove g_ether from the command line and setup a systemd service that loads g_ether later in the boot process. I had also used the module parameters file to define fixed mac addresses. This now creates the Netlink consistently after booting.

Hope this helps.

John

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.