ip address - Python IP range to IP range match -
is there method check if ip addresses network range present in subnets of ip range?
example: 10.0.1.0/18 in 123.1.0.0/8
if exists, need return true, else false.
since python 3.3, can use ipaddress module of standard library:
from ipaddress import ipv4address, ipv4network ipv4address('192.0.2.6') in ipv4network('192.0.2.0/28') # true ipv4address('10.0.1.0') in ipv4network('192.0.2.0/28') # false
if mean if networks overlap, use overlaps
:
in [14]: ipv4network('10.0.1.0/24').overlaps(ipv4network('192.0.2.0/28')) out[14]: false
note module marked provisional in python 3.3, no longer in 3.6. enjoy it!
Comments
Post a Comment