Created
August 9, 2019 23:12
-
-
Save pallas/d0783ab31631875fd714c7fd5a966df6 to your computer and use it in GitHub Desktop.
Inject MAC address into IPv6 Network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-License-Identifier: Unlicense | |
from ipaddress import IPv6Network | |
from binascii import unhexlify | |
network = IPv6Network("2001:DB8::/32") | |
mac = "12:34:56:78:9a:bc" | |
mac_bytes = b''.join(map(unhexlify, mac.split(':'))) | |
address = network[int.from_bytes(mac_bytes, byteorder='big')] | |
print(network, mac, mac_bytes, address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment