2020-01-07 17:07:34 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Nico Schottelius, 2020-01-07
|
|
|
|
# Detect the DNS64 prefix
|
|
|
|
# Based on https://tools.ietf.org/html/draft-ietf-behave-nat64-discovery-heuristic-05
|
2020-01-07 17:08:53 +00:00
|
|
|
#
|
|
|
|
# How it works:
|
|
|
|
# - ipv4only.arpa only has A records.
|
|
|
|
# - a DNS64 server will add AAAA records
|
|
|
|
# - we take this response (if any) and derive the IPv6 prefix from it
|
|
|
|
#
|
2020-01-07 17:07:34 +00:00
|
|
|
|
|
|
|
import dns.resolver
|
|
|
|
import ipaddress
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
dns64_prefix = None
|
|
|
|
answers = dns.resolver.query('ipv4only.arpa', 'AAAA')
|
|
|
|
|
|
|
|
for rdata in answers:
|
|
|
|
address = str(rdata)
|
|
|
|
network = ipaddress.IPv6Network("{}/96".format(address),
|
|
|
|
strict=False)
|
|
|
|
# print("{}: {}".format(rdata, network))
|
|
|
|
print("{}".format(network))
|