Overview¶
This package adds additional tools to the Python builtin ipaddress — IPv4/IPv6 manipulation library
Currently it only adds the functionality to define an IP allocation (a supernet) and assignments (used subnets) contained in that supernet. You then can request free subnets of a specific size from the allocation.
>>> from ipaddons import ip_allocation
>>> from itertools import islice
>>> alloc = ip_allocation("10.66.0.0/16")
>>> alloc.set_used_subnets(["10.66.0.0/24", "10.66.2.64/29", "10.66.4.128/25"])
>>> four_free_24 = list(islice(alloc.get_free_subnets(24), 4))
>>> four_free_24
[IPv4Network('10.66.1.0/24'), IPv4Network('10.66.3.0/24'), IPv4Network('10.66.5.0/24'), IPv4Network('10.66.6.0/24')]