Skip to content

Instantly share code, notes, and snippets.

@sauloperez
Created May 2, 2014 08:54
Show Gist options
  • Save sauloperez/771cfba97cf6e2397e95 to your computer and use it in GitHub Desktop.
Save sauloperez/771cfba97cf6e2397e95 to your computer and use it in GitHub Desktop.
IEEE locally-assigned MAC addresses
# Generates IEEE locally-assigned MAC addresses
# @return [String] following the pattern [0-9A-Fa-f][26AEae][0-9A-Fa-f]{10}
def mac
mac = ('%0.2X' % rand(256))[0, 1] + %w(2 6 A E).sample
mac << (1..5).map { "%0.2X" % rand(256) }.join
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment