Package netaddr :: Module address
[frames] | no frames]

Module address

source code

network addresses and associated aggregates (CIDR, Wilcard, etc).

Classes
  Addr
The base class containing common functionality for all subclasses representing various network address types.
  EUI
EUI objects represent IEEE Extended Unique Identifiers.
  IP
A class whose objects represent Internet Protocol network addresses.
  AddrRange
A block of contiguous network addresses bounded by an arbitrary start and stop address.
  CIDR
A block of contiguous IPv4 or IPv6 network addresses defined by a base network address and a bitmask prefix or subnet mask address indicating the size/extent of the subnet.
  Wildcard
A block of contiguous IPv4 network addresses defined using a wildcard style syntax.
Functions
 
nrange(start, stop, step=1, klass=None)
A generator producing sequences of network addresses based on start and stop values, in intervals of step.
source code
 
abbrev_to_cidr(addr)
Returns: A verbose CIDR from an abbreviated CIDR or old-style classful network address, None if format provided was not recognised or supported.
source code
Function Details

nrange(start, stop, step=1, klass=None)

source code 

A generator producing sequences of network addresses based on start and stop values, in intervals of step.

Parameters:
  • start - first network address as string or instance of Addr (sub)class.
  • stop - last network address as string or instance of Addr (sub)class.
  • step - (optional) size of step between addresses in range. Default is 1.
  • klass - (optional) the class used to create objects returned. Default: Addr class.
    • str returns string representation of network address
    • int, long and hex return expected values
    • Addr (sub)class or duck type* return objects of that class. If you use your own duck class, make sure you handle both arguments (addr_value, addr_type) passed to the constructor.

abbrev_to_cidr(addr)

source code 
Parameters:
  • addr - an abbreviated CIDR network address.

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

    Only supports IPv4 and IPv4 mapped IPv6 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
       ::192.168           - ::192.168.0.0/128
       ::ffff:192.168/120  - ::ffff:192.168.0.0/120
    
Returns:
A verbose CIDR from an abbreviated CIDR or old-style classful network address, None if format provided was not recognised or supported.