I had an issue where an invalid mac address was created. After some troubleshooting I found the mac_address_change.sh. Afaict it does not create universally administered unicast addresses properly. Only x0- x4- x8- xC- are unicast. Which is probably the reason why it wasn't accepted by the NIC. I traced it back to this part of the code:
Code: Select all
# very rarely the hexdump thing plus bitwise operations fails, so I repeat the MAC address generation to be sure
until echo "${MAC_ADDRESS}" | grep -qE "[0-9A-F]{2}(\:[0-9A-F]{2}){5}"
do
MAC_ADDRESS="$(printf "%012X" $(( 0x$(hexdump -n6 -e '/1 "%02X"' /dev/random) & 0xFEFFFFFFFFFF | 0x020000000000 )) | sed 's/.\{2\}/&:/g' | sed s/:$//g)"
done
Code: Select all
MAC_ADDRESS=`printf '%02x\n' $(( $(( 0x$(hexdump -n1 -e'1/1 "%02X"' /dev/urandom) >> 2 )) << 2 ))`
MAC_ADDRESS=${MAC_ADDRESS}$(hexdump -n5 -e '5/1 ":%02X"' /dev/urandom)
Code: Select all
MAC_ADDRESS="$(hexdump -n5 -e'"00" 5/1 ":%02X"' /dev/urandom)"