Skip to content

Instantly share code, notes, and snippets.

@eoldavix
Created June 21, 2016 09:16
Show Gist options
  • Select an option

  • Save eoldavix/bb712869dde65fe8a2ebd166bf220127 to your computer and use it in GitHub Desktop.

Select an option

Save eoldavix/bb712869dde65fe8a2ebd166bf220127 to your computer and use it in GitHub Desktop.
Random hardware MAC file generator
#!/usr/bin/env python
# coding=utf-8
import random
def HexGenerator():
return format(random.randrange(255), '02x')
def MacGenerator():
return "{}:{}:{}:{}:{}:{};".format(HexGenerator(),
HexGenerator(),
HexGenerator(),
HexGenerator(),
HexGenerator(),
HexGenerator()
)
def main():
with open('/tmp/macs', 'w') as f:
for i in range(0,100):
f.write("{}\n".format(MacGenerator()))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment