4M 3w4 months and 3 weeks ago
Saturday 8:30 pm
5th February 2022 ·
Saturday 8:30 pm
5th February 2022 ·

samjanis1@mirrorisland.com

Give Raspberry Pi a fixed hardware address when it keeps changing
When plugging a Raspberry Pi Zero W, or any RPi, you have probably found out it assigns a new network ID every time it connects to your computer or laptop by USB. Then, it is fed the 10.0.0.1/24 static IP to get the network connection work.
One suggestion was to configure g_ether through
/etc/modprobe.d/g_ether.conf
- but that didn't work for us.Alternatively, it turns out you can configure g_ether through
/boot/cmdline.txt
using the following steps:1. In a terminal, log in to your RPi with
ssh pi@10.0.0.2
2. Get your network IDs using
dmesg | grep MAC
The values after
HOST MAC
and MAC
will be used. (Your output might differ from this):pi@pwnagotchi:~ $ dmesg | grep MAC [ 1.691085] systemd[1]: systemd 241 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD -IDN2 +IDN -PCRE2 default-hierarchy=hybrid) [ 5.535418] usb0: HOST MAC 0e:23:91:34:09:10 [ 5.540356] usb0: MAC 42:08:8a:8d:24:78
3. Edit cmdline.txt with
sudo nano /boot/cmdline.txt
to set up g_ether:Where it says
modules-load=dwc2,g_ether
add the
HOST MAC
value for host_addr
, and the MAC
value for dev_addr
, so it now look like:modules-load=dwc2,g_ether g_ether.host_addr=0e:23:91:34:09:10 g_ether.dev_addr=42:08:8a:8d:24:78
4. Save with Ctrl+O and exit with Ctrl+X.
5. Reboot with
sudo reboot
and your device should now reconnect using the same MAC addresses as before.
Cancel esc
Cancel esc