PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB` netaddr.ip
Package netaddr :: Package ip
[hide private]
[frames] | no frames]

Package ip

Routines for IPv4 and IPv6 addresses, subnets and ranges.

Submodules [hide private]

Classes [hide private]
  BaseIP
An abstract base class for common operations shared between various IP related subclasses.
  IPAddress
An individual IPv4 or IPv6 address without a net mask or subnet prefix.
  IPListMixin
A mixin class providing shared list-like functionality to classes representing groups of IP addresses.
  IPNetwork
An IPv4 or IPv6 network or subnet.
  IPRange
An arbitrary IPv4 or IPv6 address range.
Functions [hide private]
 
parse_ip_network(module, addr, implicit_prefix=False, flags=0)
 
iter_unique_ips(*args)
Returns: A generator that flattens out IP subnets, yielding unique individual IP addresses (no duplicates).
 
cidr_abbrev_to_verbose(abbrev_cidr)
A function that converts abbreviated IPv4 CIDRs to their more verbose equivalent.
 
cidr_merge(ip_addrs)
A function that accepts an iterable sequence of IP addresses and subnets merging them into the smallest possible list of CIDRs.
 
cidr_exclude(target, exclude)
Removes an exclude IP address or subnet from target IP subnet.
 
spanning_cidr(ip_addrs)
Function that accepts a sequence of IP addresses and subnets returning a single IPNetwork subnet that is large enough to span the lower and upper bound IP addresses with a possible overlap on either end.
 
iter_iprange(start, end, step=1)
A generator that produces IPAddress objects between an arbitrary start and stop IP address with intervals of step between them.
 
iprange_to_cidrs(start, end)
A function that accepts an arbitrary start and end IP address or subnet and returns a list of CIDR subnets that fit exactly between the boundaries of the two with no overlap.
 
smallest_matching_cidr(ip, cidrs)
Matches an IP address or subnet against a given sequence of IP addresses and subnets.
 
largest_matching_cidr(ip, cidrs)
Matches an IP address or subnet against a given sequence of IP addresses and subnets.
 
all_matching_cidrs(ip, cidrs)
Matches an IP address or subnet against a given sequence of IP addresses and subnets.
Variables [hide private]
  RE_CIDR_ADJACENT = re.compile(r'^([01]+)0 \11$')
  RE_CIDR_WITHIN = re.compile(r'^([01]+) \1[10]+$')
  RE_VALID_CIDR_BITS = re.compile(r'^[01]+$')
  IPV4_LOOPBACK = IPNetwork('127.0.0.0/8')
  IPV4_PRIVATE = (IPNetwork('10.0.0.0/8'), IPNetwork('172.16.0.0...
  IPV4_LINK_LOCAL = IPNetwork('169.254.0.0/16')
  IPV4_MULTICAST = IPNetwork('224.0.0.0/4')
  IPV4_6TO4 = IPNetwork('192.88.99.0/24')
  IPV4_RESERVED = (IPNetwork('39.0.0.0/8'), IPNetwork('128.0.0.0...
  IPV6_LOOPBACK = IPAddress('::1')
  IPV6_PRIVATE = (IPNetwork('fc00::/7'), IPNetwork('fec0::/10'))
  IPV6_LINK_LOCAL = IPNetwork('fe80::/10')
  IPV6_MULTICAST = IPNetwork('ff00::/8')
  IPV6_RESERVED = (IPNetwork('ff00::/12'), IPNetwork('::/8'), IP...
  __package__ = 'netaddr.ip'
Function Details [hide private]

iter_unique_ips(*args)

 
Parameters:
  • args - A list of IP addresses and subnets passed in as arguments.
Returns:
A generator that flattens out IP subnets, yielding unique individual IP addresses (no duplicates).

cidr_abbrev_to_verbose(abbrev_cidr)

 

A function that converts abbreviated IPv4 CIDRs to their more verbose equivalent.

Parameters:
  • abbrev_cidr - an abbreviated CIDR.

    Uses the old-style classful IP address rules to decide on a default subnet prefix if one is not explicitly provided.

    Only supports IPv4 addresses.

    Examples :

       10                  - 10.0.0.0/8
       10/16               - 10.0.0.0/16
       128                 - 128.0.0.0/16
       128/8               - 128.0.0.0/8
       192.168             - 192.168.0.0/16
    
Returns:
A verbose CIDR from an abbreviated CIDR or old-style classful network address, The original value if it was not recognised as a supported abbreviation.

cidr_merge(ip_addrs)

 

A function that accepts an iterable sequence of IP addresses and subnets merging them into the smallest possible list of CIDRs. It merges adjacent subnets where possible, those contained within others and also removes any duplicates.

Parameters:
  • ip_addrs - an iterable sequence of IP addresses and subnets.
Returns:
a summarized list of IPNetwork objects.

cidr_exclude(target, exclude)

 

Removes an exclude IP address or subnet from target IP subnet.

Parameters:
  • target - the target IP address or subnet to be divided up.
  • exclude - the IP address or subnet to be removed from target.
Returns:
list of IPNetwork objects remaining after exclusion.

spanning_cidr(ip_addrs)

 

Function that accepts a sequence of IP addresses and subnets returning a single IPNetwork subnet that is large enough to span the lower and upper bound IP addresses with a possible overlap on either end.

Parameters:
  • ip_addrs - sequence of IP addresses and subnets.
Returns:
a single spanning IPNetwork subnet.

iter_iprange(start, end, step=1)

 

A generator that produces IPAddress objects between an arbitrary start and stop IP address with intervals of step between them. Sequences produce are inclusive of boundary IPs.

Parameters:
  • start - start IP address.
  • end - end IP address.
  • step - (optional) size of step between IP addresses. Default: 1
Returns:
an iterator of one or more IPAddress objects.

iprange_to_cidrs(start, end)

 

A function that accepts an arbitrary start and end IP address or subnet and returns a list of CIDR subnets that fit exactly between the boundaries of the two with no overlap.

Parameters:
  • start - the start IP address or subnet.
  • end - the end IP address or subnet.
Returns:
a list of one or more IP addresses and subnets.

smallest_matching_cidr(ip, cidrs)

 

Matches an IP address or subnet against a given sequence of IP addresses and subnets.

Parameters:
  • ip - a single IP address or subnet.
  • cidrs - a sequence of IP addresses and/or subnets.
Returns:
the smallest (most specific) matching IPAddress or IPNetwork object from the provided sequence, None if there was no match.

largest_matching_cidr(ip, cidrs)

 

Matches an IP address or subnet against a given sequence of IP addresses and subnets.

Parameters:
  • ip - a single IP address or subnet.
  • cidrs - a sequence of IP addresses and/or subnets.
Returns:
the largest (least specific) matching IPAddress or IPNetwork object from the provided sequence, None if there was no match.

all_matching_cidrs(ip, cidrs)

 

Matches an IP address or subnet against a given sequence of IP addresses and subnets.

Parameters:
  • ip - a single IP address or subnet.
  • cidrs - a sequence of IP addresses and/or subnets.
Returns:
all matching IPAddress and/or IPNetwork objects from the provided sequence, an empty list if there was no match.

Variables Details [hide private]

IPV4_PRIVATE

Value:
(IPNetwork('10.0.0.0/8'),
 IPNetwork('172.16.0.0/12'),
 IPNetwork('192.0.2.0/24'),
 IPNetwork('192.168.0.0/16'),
 IPRange('239.0.0.0', '239.255.255.255'))

IPV4_RESERVED

Value:
(IPNetwork('39.0.0.0/8'),
 IPNetwork('128.0.0.0/16'),
 IPNetwork('191.255.0.0/16'),
 IPNetwork('192.0.0.0/24'),
 IPNetwork('223.255.255.0/24'),
 IPNetwork('240.0.0.0/4'),
 IPRange('234.0.0.0', '238.255.255.255'),
 IPRange('225.0.0.0', '231.255.255.255'))

IPV6_RESERVED

Value:
(IPNetwork('ff00::/12'),
 IPNetwork('::/8'),
 IPNetwork('100::/8'),
 IPNetwork('200::/7'),
 IPNetwork('400::/6'),
 IPNetwork('800::/5'),
 IPNetwork('1000::/4'),
 IPNetwork('4000::/3'),
...