PyDocs

Nav

Internet Protocols and Support

IPv4Network

  • IPv4Network(address, strict=True)
This class represents and manipulates 32-bit IPv4 network + addresses..

Attributes: [examples for IPv4Network('192.0.2.0/27')]
    .network_address: IPv4Address('192.0.2.0')
    .hostmask: IPv4Address('0.0.0.31')
    .broadcast_address: IPv4Address('192.0.2.32')
    .netmask: IPv4Address('255.255.255.224')
    .prefixlen: 27
Changed in 3.5
  • 3.5: Added the two-tuple form for the address constructor parameter.
Members of IPv4Network

a

address_exclude
Remove an address from a larger block.

b

broadcast_address
The broadcast address for the network.

c

compare_networks
Compare two IP objects.
compressed
Return the shorthand version of the IP address as a string.

e

exploded
Return the longhand version of the IP address as a string.

h

hostmask
The host mask, as an IPv4Address object.
hosts
Generate Iterator over usable hosts in a network.

i

is_link_local
Test if the address is reserved for link-local.
is_loopback
Test if the address is a loopback address.
is_multicast
Test if the address is reserved for multicast use.
is_private
Test if this network belongs to a private range.
is_reserved
Test if the address is otherwise IETF reserved.
is_unspecified
Test if the address is unspecified.

m

max_prefixlen
Refer to the corresponding attribute documentation in IPv4Address.

n

netmask
The net mask, as an IPv4Address object.
network_address
The network address for the network.
num_addresses
Number of hosts in the current subnet.

o

overlaps
Tell if self is partly contained in other.

p

prefixlen
Length of the network prefix, in bits.

s

subnet_of
Return True if this network is a subnet of other.
subnets
The subnets which join to make the current subnet.
supernet
The supernet containing the current network.
supernet_of
Return True if this network is a supernet of other.

v

version
Refer to the corresponding attribute documentation in IPv4Address.

w

with_hostmask
A string representation of the network, with the mask in host mask notation.
with_netmask
A string representation of the network, with the mask in net mask notation.
with_prefixlen
A string representation of the network, with the mask in prefix notation.
1 Example
>>> for addr in IPv4Network('192.0.2.0/28'):
...     addr
...
IPv4Address('192.0.2.0')
IPv4Address('192.0.2.1')
IPv4Address('192.0.2.2')
IPv4Address('192.0.2.3')
IPv4Address('192.0.2.4')
IPv4Address('192.0.2.5')
IPv4Address('192.0.2.6')
IPv4Address('192.0.2.7')
IPv4Address('192.0.2.8')
IPv4Address('192.0.2.9')
IPv4Address('192.0.2.10')
IPv4Address('192.0.2.11')
IPv4Address('192.0.2.12')
IPv4Address('192.0.2.13')
IPv4Address('192.0.2.14')
IPv4Address('192.0.2.15')
from the Python docs
See Also
No see-alsos for ipaddress/IPv4Network
0 Notes
No notes for IPv4Network