Package netaddr :: Package ip :: Module nmap
[hide private]
[frames] | no frames]

Module nmap

Routines for dealing with nmap-style IPv4 address ranges.

The nmap range specification represents between 1 and 4 contiguous IP address blocks depending on the range specified.

Each octets can be represented with hyphenated range sets according to the following rules:

  1. * 'x-y' - the hyphenated octet (represents values x through y)
  2. x must be less than or equal to y
  3. x and y must be values between 0 through 255

Example nmap ranges :

   '192.0.2.1'                 #   one IP address
   '192.0.2.0-31'              #   one block with 32 IP addresses.
   '192.0.2-3.1-254'           #   two blocks with 254 IP addresses.
   '0-255.0-255.0-255.0-255'   #   the whole IPv4 address space
Functions [hide private]
 
valid_nmap_range(iprange)
Returns: True if IP range is valid, False otherwise.
 
iter_nmap_range(iprange)
The nmap security tool supports a custom type of IPv4 range using multiple hyphenated octets.
Variables [hide private]
  __package__ = 'netaddr.ip'
Function Details [hide private]

valid_nmap_range(iprange)

 
Parameters:
  • iprange - an nmap-style IP address range.
Returns:
True if IP range is valid, False otherwise.

iter_nmap_range(iprange)

 

The nmap security tool supports a custom type of IPv4 range using multiple hyphenated octets. This generator provides iterators yielding IP addresses according to this rule set.

Parameters:
  • iprange - an nmap-style IP address range.
Returns:
an iterator producing IPAddress objects for each IP in the range.