Skip to content

Instantly share code, notes, and snippets.

@Caffe1neAdd1ct
Created October 6, 2017 09:35
Show Gist options
  • Save Caffe1neAdd1ct/2298eef96f1a87521b3657c675a71dcd to your computer and use it in GitHub Desktop.
Save Caffe1neAdd1ct/2298eef96f1a87521b3657c675a71dcd to your computer and use it in GitHub Desktop.
Generate mac addresses
#!/usr/bin/python
# macgen.py script to generate a MAC address for guests on Xen
#
import random
#
def randomMAC():
mac = [ 0x00, 0x16, 0x3e,
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
return ':'.join(map(lambda x: "%02x" % x, mac))
#
print randomMAC()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment