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

1 comment:

  1. Video Downloader for Mac - Total Video Downloader for Mac is a perfect Video Downloader Mac ,which can fastest download online videos from YouTube and tons of video sites for your Mac.

    ReplyDelete