Skip to content

Instantly share code, notes, and snippets.

@nboubakr
Created May 10, 2014 11:08
Show Gist options
  • Save nboubakr/c3a6e3edf04b8c6be113 to your computer and use it in GitHub Desktop.
Save nboubakr/c3a6e3edf04b8c6be113 to your computer and use it in GitHub Desktop.
Generate a random MAC Address using the VM OUI code.
import random
def generate_random_mac_address():
"""Generate a random MAC Address using the VM OUI code"""
rand_mac_addr = [0x00, 0x50, 0x56, random.randint(0x00, 0x7f), random.randint(0x00, 0xff), random.randint(0x00, 0xff)]
return ':'.join(map(lambda x: "%02x" % x, rand_mac_addr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment