Given two CIDR addresses say 192.168.2.0/14 and 192.168.2.0/32
How do I check if two ip addresses overlap in \"python2.6\"??
I have gone through netaddr and
If don't have netaddr at hand for testing, but I think you could check if the first and last address of the first network are both contained in the second:
net_1 = IPNetwork("192.168.2.0/14")
net_2 = IPNetwork("192.168.2.0/32")
if net_1.first in net_2 and net_1.last in net_2:
# do something
BTW, IPNetwork line 1102 defines a __contains__ method. But I'm not certain the line 1127 isn't broken ? You should test and report a bug if it is.