Skip to content

Instantly share code, notes, and snippets.

@enko
Last active August 29, 2015 14:16
Show Gist options
  • Save enko/37e901e61a270819ad02 to your computer and use it in GitHub Desktop.
Save enko/37e901e61a270819ad02 to your computer and use it in GitHub Desktop.
Convert MAC to IPv6 linklocal
#!/usr/local/bin/python
def mac2ll(mac):
mac = mac.split(":")
mac.insert(3,'fe')
mac.insert(3,'ff')
mac[0] = str(int(mac[0]) ^ 6)
return "fe80::%s:%s:%s:%s" % ("".join(mac[0:2]),"".join(mac[2:4]),"".join(mac[4:6]),"".join(mac[6:8]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment