[IPv6 #1] IPv6 address uniqueness

This commit is contained in:
kjg 2020-07-22 23:48:42 +09:00
parent bff795f6f0
commit 6a46f7f657

21
kjg/IPv6/overlap.py Normal file
View file

@ -0,0 +1,21 @@
from sys import argv
import ipaddress
# read the argument how to run this
try:
script, ip1, ip2 = argv
a = ip1.split('/')
b = ip2.split('/')
a = ipaddress.ip_network(a[0]).supernet(new_prefix=int(a[1]))
b = ipaddress.ip_network(b[0]).supernet(new_prefix=int(b[1]))
test1 = ipaddress.IPv6Network(a).overlaps(ipaddress.IPv6Network(b))
if test1 :
print("overlap")
else:
print("no overlap")
except:
print("wrong inpit")