Create a gist now

Instantly share code, notes, and snippets.

@krhitoshi /macgen.rb
Last active Aug 29, 2015

What would you like to do?
#!/usr/bin/env ruby
# Xen
#mac = [0x00, 0x16, 0x3e, Random.rand(0x7f), Random.rand(0xff), Random.rand(0xff)]
# QEMU or KVM
mac = [0x52, 0x42, 0x00, Random.rand(0x7f), Random.rand(0xff), Random.rand(0xff)]
puts (["%02x"] * 6).join(":") % mac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment