Rock Pi S Wifi MAC Address Changes

Using Armbian_22.05.0-trunk_Rockpi-s_bullseye_current_5.15.35_minimal.img with a Rock Pi S to run a back-up Pi-Hole, and I’m finding that the MAC address of the WiFi adapter changes each reboot - preventing me from using my router’s DHCP settings to establish a static IP.

From what I’ve read in the forums, the ethernet MAC address is stable, but unfortunately I am out of ethernet ports on my router.

Is there anything that can be done to establish a stable WiFi MAC address?

Me too :slight_smile:
I created udev scripts to derive a fixed Ethernet address from the UUID of the root partition.
Thus, each machine’s WiFi should have a unique, fixed WiFi MAC address.

Note that that ‘42’ argument in macaddr.rules should be different for each network interface whose Ethernet address is being assigned this way.

a single line
/etc/udev/rules.d/05-wlan0-macaddr.rules:
KERNEL==“wlan0”, ACTION==“add” RUN+=“fixEtherAddr %k 42”

This file must be made executable (chmod +x /lib/udev/fixEtherAddr)
/lib/udev/fixEtherAddr:
#################
#!/bin/sh
#Assign specified interface a fixed, unique Ethernet MAC address constructed
#as given prefix byte followed by 1st five bytes of the root partition’s UUID.
#Ethernet prefix byte value less 2 should be exactly divisible by 4
#e.g. (prefix - 2) % 4 == 0

[ “$2” ] || {
echo “Specify network interface and first Ethernet address byte in hex” >&2
exit 1
}

ethaddr() {
echo -n “$1”
/bin/lsblk -no UUID /bin/findmnt -no SOURCE / |
/bin/tr -d ‘-’ | /bin/fold -b2 |
for byte in 1 2 3 4 5; do read hex; echo -n “:$hex”; done
}

/usr/sbin/ifconfig $1 hw ether ethaddr $2
##############

@genosensor this is super interesting, thank you for sharing. I’m quite new to poking around Linux but will give this a try at some point!