Ipaddress — ipv4/ipv6 manipulation library — python 3.8. documentation

Network objects

All attributes implemented by address objects are implemented by network objects too. Additionally, network objects implement additional attributes. Many of these are typical between IPv4Network and IPv6Network, to avoid duplication they’re only documented for IPv4Network. Network objects are hashable, so that they can be used keys in dictionaries.

class ipaddress.IPv4Network(address, strict=True)

Construct an IPv4 network definition. address may be one of the next:

  1. A string composed of the Ip as well as an optional mask, separated by a slash (/). The Ip may be the network address, and also the mask could be whether single number, meaning it’s a prefix, or perhaps a string representation of the IPv4 address. If it is the second, the mask is construed like a internet mask if it comes down to a non-zero field, or like a host mask if it comes down to a zero field, using the single exception of an exciting-zero mask that is treated like a internet mask. If no mask is supplied, it’s regarded as /32.

    Network objects

    All attributes implemented by address objects are implemented by network objects too. Additionally, network objects implement additional attributes. Many of these are typical between IPv4Network and IPv6Network, to avoid duplication they’re only documented for IPv4Network. Network objects are hashable, so that they can be used keys in dictionaries.

    class ipaddress.IPv4Network(address, strict=True)

    Construct an IPv4 network definition. address may be one of the next:

    1. A string composed of the Ip as well as an optional mask, separated by a slash (/). The Ip may be the network address, and also the mask could be whether single number, meaning it’s a prefix, or perhaps a string representation of the IPv4 address. If it is the second, the mask is construed like a internet mask if it comes down to a non-zero field, or like a host mask if it comes down to a zero field, using the single exception of an exciting-zero mask that is treated like a internet mask. If no mask is supplied, it’s regarded as /32.

      For instance, the next address specifications are equivalent: 192.168.1./24, 192.168.1./255.255.255. and 192.168.1./…255.

    2. An integer that matches into 32 bits. This is the same as a single-address network, using the network address being address and the mask being /32.

    3. An integer packed right into a bytes object of length 4, big-endian. The interpretation is comparable to an integer address.

    4. A 2-tuple of the address description along with a netmask, in which the address description will be an string, a 32-bits integer, a 4-bytes packed integer, or perhaps an existing IPv4Address object and also the netmask is either an integer representing the prefix length (e.g. 24) or perhaps a string representing the prefix mask (e.g. 255.255.255.).

    An AddressValueError is elevated if address isn’t a valid IPv4 address. A NetmaskValueError is elevated when the mask isn’t valid for an IPv4 address.

    If strict is True and host bits are positioned within the provided address, then ValueError is elevated. Otherwise, the host bits are masked out to look for the appropriate network address.

    Unless of course mentioned otherwise, all network methods accepting other network/address objects will raise TypeError when the argument’s IP version is incompatible to self.

    Ipaddress — ipv4/ipv6 manipulation library — python 3.8. documentation the IPv4 address

    Resourse: https://docs.python.org/3/library/

    Ipaddress — ipv4/ipv6 manipulation library — python 3.8. documentation exciting-zero mask that

    Understanding an IP Address: Cisco Router Training 101