18 lines
559 B
Python
18 lines
559 B
Python
|
#!/usr/bin/python
|
||
|
# macgen.py script to generate a MAC address for guests on Xen
|
||
|
# from https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Virtualization/sect-Virtualization-Tips_and_tricks-Generating_a_new_unique_MAC_address.html
|
||
|
# usefull to generate the mac for a virtual machine
|
||
|
#
|
||
|
# run
|
||
|
# python2 macgen.py
|
||
|
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())
|