import ipaddress def overlapip(ip1, ip2): test1 = ipaddress.IPv6Network(ip1).overlaps(ipaddress.IPv6Network(ip2)) if test1 : print("overlap") return 0 else: print("no overlap") return 1