Showing posts with label Virtualization. Show all posts
Showing posts with label Virtualization. Show all posts

Sunday, 13 April 2014

Generate random MAC Address with bash on Linux



It can be useful to be able to quickly generate a Random MAC address with virtual environments like KVM. The following is a method which always sets the first octet as 00 which can be set as required. 

$ MACAddress=$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/00:\2:\3:\4:\5:\6/')

$ echo $MACAddress
00:6c:39:6d:32:c4