Skip to content

Instantly share code, notes, and snippets.

@maltzsama
Created April 16, 2013 17:35
Show Gist options
  • Select an option

  • Save maltzsama/5397874 to your computer and use it in GitHub Desktop.

Select an option

Save maltzsama/5397874 to your computer and use it in GitHub Desktop.
mac address python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
fd = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
fd.bind(('eth0', 9999))
mac = fd.getsockname()[-1]
print ':'.join(['%02x' % ord(n) for n in mac])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment