I was in a situation where I was trying to decode mac addresses to the vendor for a project I was working on. I found an online api that would do this, but that requires me to send my Mac Address to someone else, and I would HAVE to be online to run this tool. I was looking for something that could run offline and not require a live outbound connection.
#!/usr/bin/env python from netaddr import EUI, OUI def hardware_vendor(mac): """ This function will take a mac address The pull out the oui and analyze it. """ try: hw_id = EUI(mac) oui = hw_id.oui return oui.registration() except NotRegisteredError, err: return 'Error="%s"' % err if __name__ == '__main__': print hardware_vendor('<mac address>')
After running this I could then get the output of the vendor. if I was going to write this in a standalone script I would consider taking the mac address in as a command line argument.