Represents blocks of IPv4 and IPv6 addresses using CIDR (Classless
Inter-Domain Routing) notation.
CIDR is a method of categorising contiguous blocks of both IPv4 and
IPv6 addresses. It is very scalable allowing for the optimal usage of the
IP address space. It permits the aggregation of networks via route
summarisation (supernetting) where adjacent routes can be combined into a
single route easily. This greatly assists in the reduction of routing
table sizes and improves network router efficiency.
CIDR blocks are represented by a base network address and a prefix
indicating the size of the (variable length) subnet mask. These are
separated by a single '/' character. Subnet sizes increase in powers of
base 2 aligning to bit boundaries.
It is technically invalid to have non-zero bits in a CIDR address to
the right of the implied netmask. For user convenience this is however
configurable and can be disabled using a constructor argument.
where the x's represent the network address and y is the netmask
prefix between 0 and 32.
where the x's represent the network address and y is the netmask
prefix between 0 and 128.
where the y's represent a valid netmask.
Akin to Cisco's ACL (Access Control List) bitmasking (reverse
netmasks).
where the y's represent a valid hostmask.
Reference: RFCs 1338 and 4632.
|
__init__(self,
cidr,
fmt=<class 'netaddr.address.IP'>,
strict=True,
expand_abbrev=True)
Constructor. |
source code
|
|
|
|
|
__add__(self,
other)
Add another CIDR to this one returning a CIDR supernet that will
contain both in the smallest possible sized range. |
source code
|
|
|
|
|
next(self,
step=1)
Returns:
The immediate (adjacent) successor of this CIDR. |
source code
|
|
|
iter_host_addrs(self)
Returns:
An iterator object providing access to all valid host IP addresses
within the specified CIDR block. |
source code
|
|
|
supernet(self,
prefixlen=0,
fmt=None)
Provides a list of supernet CIDRs for the current CIDR between the
size of the current prefix and (if specified) the end CIDR prefix. |
source code
|
|
|
subnet(self,
prefixlen,
count=None,
fmt=None)
A generator that returns CIDR subnets based on the current network
base address and provided CIDR prefix and count. |
source code
|
|
|
|
|
|
|
|
Inherited from object :
__delattr__ ,
__getattribute__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__
|
|
__contains__(self,
addr)
Returns:
True if given address or range falls within this range,
False otherwise. |
source code
|
|
|
__eq__(self,
other)
Returns:
True if the boundaries of this range are the same as
other, False otherwise. |
source code
|
|
|
__ge__(self,
other)
Returns:
True if the boundaries of this range are greater or
equal to other, False otherwise. |
source code
|
|
|
__getitem__(self,
index)
Returns:
The IP address(es) in this address range referenced by index/slice. |
source code
|
|
|
__gt__(self,
other)
Returns:
True if the boundaries of this range are greater than
other, False otherwise. |
source code
|
|
|
|
|
__iadd__(self,
i)
Increments start and end addresses of this range by the current size. |
source code
|
|
|
__isub__(self,
i)
Decrements start and end addresses of this range by the current size. |
source code
|
|
|
__iter__(self)
Returns:
An iterator object providing access to all network addresses within
this range. |
source code
|
|
|
__le__(self,
other)
Returns:
True if the boundaries of this range are less or equal
to other, False otherwise. |
source code
|
|
|
|
|
__lt__(self,
other)
Returns:
True if the boundaries of this range are less than
other, False otherwise. |
source code
|
|
|
__ne__(self,
other)
Returns:
True if the boundaries of this range are not the same as
other, False otherwise. |
source code
|
|
|
adjacent(self,
other)
Returns:
True if other's boundary touches the boundary of this address range,
False otherwise. |
source code
|
|
|
format(self,
int_addr,
fmt=None)
Returns:
a network address in the format returned after passing it through
this object's fmt property callable. |
source code
|
|
|
|
|
issubnet(self,
other)
Returns:
True if other's boundary is equal to or within this range. |
source code
|
|
|
issupernet(self,
other)
Returns:
True if other's boundary is equal to or contains this range. |
source code
|
|
|
overlaps(self,
other)
Returns:
True if other's boundary crosses the boundary of this address range,
False otherwise. |
source code
|
|
|
size(self)
Returns:
The total number of network addresses in this range. |
source code
|
|
|
tuple(self)
Returns:
A 3-element tuple (first, last, addr_type) which represent the basic
details of this IPRange object. |
source code
|
|
|
|