Skip to content

Instantly share code, notes, and snippets.

@sonalranjit
Forked from pklaus/README.md
Created August 23, 2016 20:50
Show Gist options
  • Select an option

  • Save sonalranjit/639e0c3a4095d2f7cfab45ca9d972cf5 to your computer and use it in GitHub Desktop.

Select an option

Save sonalranjit/639e0c3a4095d2f7cfab45ca9d972cf5 to your computer and use it in GitHub Desktop.

Revisions

  1. @pklaus pklaus revised this gist Mar 19, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion randmac.py
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    import random

    def randomMAC():
    mac = [ 0x00, 0x16, 0x3e,
    return [ 0x00, 0x16, 0x3e,
    random.randint(0x00, 0x7f),
    random.randint(0x00, 0xff),
    random.randint(0x00, 0xff) ]
  2. @pklaus pklaus revised this gist Mar 19, 2014. 2 changed files with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,6 @@ TODO

    * [MAC Adress](http://en.wikipedia.org/wiki/MAC_address) on Wikipedia
    * redhat's virtualization guide on [Generating a new unique MAC address](http://goo.gl/rtt5T8)
    * A Perl Script that does the same: [randmac.pl](http://www.hellion.org.uk/cgi-bin/randmac.pl?source=1)
    * A Perl Script that does the same: [randmac.pl](http://www.hellion.org.uk/cgi-bin/randmac.pl?source=1)
    * The python module [`netaddr`](https://pypi.python.org/pypi/netaddr) can help you work with MAC addresses.

    Empty file modified randmac.py
    100644 → 100755
    Empty file.
  3. @pklaus pklaus created this gist Mar 19, 2014.
    13 changes: 13 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    TODO

    * Create a CLI-Interface with the following options:
    * Unicast or Multicast? Default: Unicast
    * Locally Administered or Globally Unique? Default: Locally Administered
    * Prescribe specific OUI (overwrites the above two)
    * Number of MACs to generate (they should not collide and be piped out separated by newlines)

    ### Resources

    * [MAC Adress](http://en.wikipedia.org/wiki/MAC_address) on Wikipedia
    * redhat's virtualization guide on [Generating a new unique MAC address](http://goo.gl/rtt5T8)
    * A Perl Script that does the same: [randmac.pl](http://www.hellion.org.uk/cgi-bin/randmac.pl?source=1)
    15 changes: 15 additions & 0 deletions randmac.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/usr/bin/env python

    import random

    def randomMAC():
    mac = [ 0x00, 0x16, 0x3e,
    random.randint(0x00, 0x7f),
    random.randint(0x00, 0xff),
    random.randint(0x00, 0xff) ]

    def MACprettyprint(mac):
    return ':'.join(map(lambda x: "%02x" % x, mac))

    if __name__ == '__main__':
    print(MACprettyprint(randomMAC()))