An IPv4 or IPv6 network or subnet. A combination of an IP address and
a network mask.
where 'y' address represent a valid netmask.
where 'y' address represent a valid netmask.
This is like Cisco's ACL bitmasks.
d) Abbreviated CIDR format (as of netaddr 0.7.x this requires the
optional constructor argument implicit_prefix=True
):
|
__init__(self,
addr,
implicit_prefix=False,
version=None,
flags=0)
Constructor. |
|
|
|
__getstate__(self)
Returns:
Pickled state of an IPNetwork object. |
|
|
|
|
|
_set_prefixlen(self,
value) |
|
|
|
__iadd__(self,
num)
Increases the value of this IPNetwork object by the current size multiplied by
num . |
|
|
|
__isub__(self,
num)
Decreases the value of this IPNetwork object by the current size multiplied by
num . |
|
|
|
key(self)
Returns:
A key tuple used to uniquely identify this IPNetwork. |
|
|
|
sort_key(self)
Returns:
A key tuple used to compare and sort this IPNetwork
correctly. |
|
|
|
ipv4(self)
Returns:
A numerically equivalent version 4 IPNetwork
object. |
|
|
|
ipv6(self,
ipv4_compatible=False)
Please Note: the IPv4-mapped IPv6 address format is now
considered deprecated. |
|
|
|
|
|
next(self,
step=1)
Returns:
The adjacent subnet succeeding this IPNetwork
object. |
|
|
|
supernet(self,
prefixlen=0)
Provides a list of supernets for this IPNetwork
object between the size of the current prefix and (if specified) an
endpoint prefix. |
|
|
|
subnet(self,
prefixlen,
count=None,
fmt=None)
A generator that divides up this IPNetwork's subnet into smaller
subnets based on a specified CIDR prefix. |
|
|
|
iter_hosts(self)
Returns:
An iterator that provides all IP addresses that can be assigned to
hosts within the range of this IP object's subnet. |
|
|
|
__str__(self)
Returns:
this IPNetwork in CIDR format |
|
|
|
__repr__(self)
Returns:
Python statement to create an equivalent object |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
|
|
|
__ge__(self,
other)
Returns:
True if this IPAddress or IPNetwork
object is greater than or equal to other ,
False otherwise. |
|
|
|
|
|
__hash__(self)
Returns:
A hash value uniquely indentifying this IP object. |
|
|
|
__le__(self,
other)
Returns:
True if this IPAddress or IPNetwork
object is less than or equal to other ,
False otherwise. |
|
|
|
|
|
|
|
|
|
is_ipv4_compat(self)
Returns:
True if this IP is IPv4-mapped IPv6 address,
False otherwise. |
|
|
|
is_ipv4_mapped(self)
Returns:
True if this IP is IPv4-compatible IPv6 address,
False otherwise. |
|
|
|
is_link_local(self)
Returns:
True if this IP is link-local address False
otherwise. |
|
|
|
is_loopback(self)
Returns:
True if this IP is loopback address (not for network
transmission), False otherwise. |
|
|
|
is_multicast(self)
Returns:
True if this IP is multicast, False
otherwise |
|
|
|
is_private(self)
Returns:
True if this IP is for internal/private use only (i.e. |
|
|
|
is_reserved(self)
Returns:
True if this IP is in IANA reserved range,
False otherwise. |
|
|
|
is_unicast(self)
Returns:
True if this IP is unicast, False otherwise |
|
|
|
__bool__(self)
Ranged IP objects always represent a sequence of at least one IP
address and are therefore always True in the boolean context. |
|
|
|
__contains__(self,
other)
Returns:
True if other falls within the boundary of this one,
False otherwise. |
|
|
|
__getitem__(self,
index)
Returns:
The IP address(es) in this IPNetwork object referenced by index or slice. |
|
|
|
__iter__(self)
Returns:
An iterator providing access to all IPAddress
objects within range represented by this ranged IP object. |
|
|
|
__len__(self)
Returns:
the number of IP addresses in this ranged IP object. |
|
|
|
__nonzero__(self)
Ranged IP objects always represent a sequence of at least one IP
address and are therefore always True in the boolean context. |
|
|
|
prefixlen
size of the bitmask used to separate the network from the host bits
|
|
ip
The IP address of this IPNetwork object.
|
|
network
The network address of this IPNetwork object.
|
|
broadcast
The broadcast address of this IPNetwork
object
|
|
first
The integer value of first IP address found within this IPNetwork
object.
|
|
last
The integer value of last IP address found within this IPNetwork
object.
|
|
netmask
The subnet mask of this IPNetwork object.
|
|
hostmask
The host mask of this IPNetwork object.
|
|
cidr
The true CIDR address for this IPNetwork
object which omits any host bits to the right of the CIDR subnet
prefix.
|
|
_prefixlen
|
Inherited from object :
__class__
|
|
_module
|
|
_value
|
|
info
A record dict containing IANA registration details for this IP
address if available, None otherwise.
|
|
value
a positive integer representing the value of IP address/subnet.
|
|
version
the IP protocol version represented by this IP object.
|
|
size
The total number of IP addresses within this ranged IP object.
|