Me too
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
##############