March 2019
Beginner
490 pages
12h 40m
English
We can also find the subnet information from the IPv6Network objects, as follows:
>>> subnets = list(net6.subnets()) >>> subnets [IPv6Network('2001:db8::/49'), IPv6Network('2001:db8:0:8000::/49')]
The ipaddress module includes various functions to create subnets and supernets, so we can check whether a network overlaps:
>>> ipnet = ipaddress.IPv6Network("2001:db8::/48") >>> list(ipnet.subnets()) [IPv6Network('2001:db8::/49'), IPv6Network('2001:db8:0:8000::/49')]
We can use the subnets method to expand the network mask and obtain new networks:
>>> list(ipnet.subnets(prefixlen_diff=4)) [IPv6Network('2001:db8::/52'), IPv6Network('2001:db8:0:1000::/52'), IPv6Network('2001:db8:0:2000::/52'), IPv6Network('2001:db8:0:3000::/52'), ...Read now
Unlock full access