Posted By

ksaver on 04/07/11


Tagged

python ethernet macaddress


Versions (?)

random_mac()


 / Published in: Python
 

This python function generates a valid(random(mac address string)) :-)

  1. #! /usr/bin/env python
  2. import random
  3. def random_mac():
  4. mac = ['00']
  5. for i in xrange(5):
  6. octet = random.randint(0, 255)
  7. #mac_addr.append(hex(octet)[2:].zfill(2))
  8. mac.append('%02X' % octet)
  9. return ':'.join(mac)
  10.  
  11. print random_mac()

Report this snippet  

You need to login to post a comment.