On this page
ipaddress.IPv6Network
Prev: ipaddress.IPv6Interface | Up: ipaddress | Next: ipaddress.NetmaskValueError
Rel: ipaddress.AddressValueError, ipaddress.collapse_addresses, ipaddress.get_mixed_type_key, ipaddress.ip_address
Ref: docs.python.org — ipaddress.IPv6Network
Tags: #public #python3 #stdlib #ipaddress
Import
import ipaddress
from ipaddress import IPv6Network
Signature & Overview
ipaddress.IPv6Network(address, strict=True)
This class represents and manipulates 128-bit IPv6 networks.
Methods & Attributes
IPv6Network.address_exclude(self, other)— Remove an address from a larger block.IPv6Network.compare_networks(self, other)— Compare two IP objects.IPv6Network.compressed(...)— Return the shorthand version of the IP address as a string.IPv6Network.exploded(...)— Return the longhand version of the IP address as a string.IPv6Network.hosts(self)— Generate Iterator over usable hosts in a network.IPv6Network.is_global(...)— Test if this address is allocated for public networks.IPv6Network.is_link_local(...)— Test if the address is reserved for link-local.IPv6Network.is_loopback(...)— Test if the address is a loopback address.IPv6Network.is_multicast(...)— Test if the address is reserved for multicast use.IPv6Network.is_private(...)— Test if this network belongs to a private range.IPv6Network.is_reserved(...)— Test if the address is otherwise IETF reserved.IPv6Network.is_site_local(...)— Test if the address is reserved for site-local.IPv6Network.is_unspecified(...)— Test if the address is unspecified.IPv6Network.num_addresses(...)— Number of hosts in the current subnet.IPv6Network.overlaps(self, other)— Tell if self is partly contained in other.IPv6Network.prefixlen(...)—IPv6Network.prefixlenmethod/property.IPv6Network.reverse_pointer(...)— The name of the reverse DNS pointer for the IP address, e.g.: >>> ipaddress.ip_address("127.0.0.1").reverse_pointer '1.0.0.127.in-addr.arpa'IPv6Network.subnet_of(self, other)— Return True if this network is a subnet of other.IPv6Network.subnets(self, prefixlen_diff=1, new_prefix=None)— The subnets which join to make the current subnet.IPv6Network.supernet(self, prefixlen_diff=1, new_prefix=None)— The supernet containing the current network.IPv6Network.supernet_of(self, other)— Return True if this network is a supernet of other.IPv6Network.with_hostmask(...)—IPv6Network.with_hostmaskmethod/property.IPv6Network.with_netmask(...)—IPv6Network.with_netmaskmethod/property.IPv6Network.with_prefixlen(...)—IPv6Network.with_prefixlenmethod/property.
Usage
import ipaddress
net = ipaddress.IPv6Network("2001:db8::/64")
assert ipaddress.IPv6Address("2001:db8::1") in net
Gotchas
- Never call
list(net.hosts())on a/64: It contains $2^{64}$ addresses—index (net[1]) or iterate lazily.
REPL Inspect
from ipaddress import IPv6Network
help(IPv6Network)
Linked from
Related notes
- tuts/python3/stdlib_module/ipaddress/IPv6Interface Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/NetmaskValueError Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ipaddress/AddressValueError Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/collapse_addresses Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/get_mixed_type_key Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_address Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_interface shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_network shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/IPv4Address shared tags: #ipaddress, #stdlib