29 lines
789 B
Python
Raw Normal View History

2020-12-10 07:24:56 -05:00
#!/usr/bin/env python3
2020-08-05 17:14:30 -04:00
import hashlib
import time
import uuid
def get_eui64():
mac = uuid.getnode()
eui64 = mac >> 24 << 48 | 0xfffe000000 | mac & 0xffffff
eui64_canon = "-".join([format(eui64, "02X")[i:i+2] for i in range(0, 18, 2)])
return eui64_canon
def time_ntpformat():
# Seconds relative to 1900-01-01 00:00
return time.time() - time.mktime((1900, 1, 1, 0, 0, 0, 0, 1, -1))
def main():
h = hashlib.sha1()
2020-12-10 07:24:56 -05:00
h.update(str(get_eui64() + str(time_ntpformat())).encode("utf-8"))
2020-08-05 17:14:30 -04:00
globalid = h.hexdigest()[0:10]
prefix = ":".join(("fd" + globalid[0:2], globalid[2:6], globalid[6:10]))
2020-12-10 07:24:56 -05:00
print("Prefix: " + prefix + "::/48")
print("First subnet: " + prefix + "::/64")
print("Last subnet: " + prefix + ":ffff::/64")
2020-08-05 17:14:30 -04:00
if __name__ == "__main__":
main()