You probably know that MAC address can be generated, for instance, in the following way:
macaddr=$(dd if=/dev/random bs=1024 count=1 2>/dev/null|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/') echo $macaddr
But this method can result in MAC address that looks like this one:
07:d4:51:9f:50:6c . You simply can't use the address . If you tried, you would get this error:
# ip link set dev wlan0 address $macaddr RTNETLINK answers: Cannot assign requested address
So the line above should be rewritten. And the question is how it should look like so the MAC address always was valid?