Maybe less awkward for the MAC address generation …
# get raw random 48 bit number from uuidgen
macr=`uuidgen -r | cut -d - -f 5`
# clear bits 40 and 41
topb=`printf '%02x' "$(( 0x${macr:0:2} & 0xFC ))"`
macr=$topb${macr:2}
# format as a MAC address
mac=
for b in `echo $macr | fold -w 2` ; do
mac=$mac$b:
done
mac=${mac:0:17}
I didn’t check the masking of the bits very carefully so e.&o.e. ![]()