RNDIS Ethernet Gadget RPi0w

Pwnagotchi on MacOS Catalina

The pwnagotchi project has been great fun to toy around with for the last couple weeks.

The RPi0w uses one of the micro USB ports as a USB ethernet device. You can create a small network to connect to the pwnagotchi and make configuration changes.

One issue I’ve noticed is that, on MacOS Catalina, every time the RPi0w reboots it shows up as a new RNDIS ethernet gadget. This wouldn’t be a problem except that you need to manually configure this device with the 10.0.0.1/24 network information.

MacOS Catalina Network settings showing multiple RNDIS ethernet gadget interfaces
Multiple RNDIS Ethernet Gadgets showing from one RPi0w through reboots

The pwnagotchi image makes the RNDIS Ethernet Gadget generate a random MAC address on each boot. After some searching I was able to find this post on a Raspberry Pi forum that mentioned how to make the g_ether driver use a fixed MAC address.

Re: Having issues with MacOS Catalina and gadget mode
Quote
Wed Oct 23, 2019 3:03 pm
Setting the MAC address to a specific value did fix my problem. Thanks for that. I did it in the cmdline.txt file.

I added the following to cmdline.txt:

modules-load=dwc2,g_ether g_ether.host_addr=00:22:82:ff:ff:20 g_ether.dev_addr=00:22:82:ff:ff:22

I put it after the rootwait

I should have thought of that.

Thanks.
Mark

So, I’ve edited my cmdline.txt to look like this:

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether g_ether.host_addr=de:ad:be:ef:00:10 g_ether.dev_addr=de:ad:be:ef:00:12 

Once I made the change at the end and rebooted my pwnagotchi created yet another RNDIS ethernet gadget, but once that’s configured it doesn’t create another interface after reboots!

I made the same change to my second pwnagotchi (different MAC address, obviously) and got the same results. Evidence to support a solution!

There’s probably a more elegant method to get the same result, but for now this is working as well as I need it to on my devices. I suspect a similar solution can be found within /etc/interfaces.d, but that’s some research for another blog post.