Skip to main content

Simple python-based command-line utilities to work with CIDRs individual IPs.

Project description

ipwrangle

Simple python-based command-line utilities to work with CIDRs individual IPs.

Usage

ipwrangle is installed as four command-line utility accessible as innet, netlen, ipreduce and ipexpand from the command-line.

You can use it them to convert a CIDR notation into the list of IP addresses contained in the block, reduce a list of IP addresses into its smallest CIDR blocks possible, calculate a CIDR block size or check if an IP is in a CIDR block.

An example of expansion:

-$ ipexpand 192.0.2.0/24 | head -n10
192.0.2.0
192.0.2.1
192.0.2.2
192.0.2.3
192.0.2.4
192.0.2.5
192.0.2.6
192.0.2.7
192.0.2.8
192.0.2.9

Reduction:

-$ ipexpand 192.0.2.0/24 | head -n10 | ipreduce
192.0.2.0/29
192.0.2.8/31

Network size:

-$ netlen netlen 2001:db4::/56
4722366482869645213696

IP in CDIR block, this utility writes on stderr (for human reading) but also has a return code of 0 (true) -1 (false) to use in automation:

-$ innet 192.168.0.1 192.168.0.0/24
true
-$ echo $?
0
-$ innet 192.169.0.1 192.168.0.0/24
false
-$ echo $?
255

All tools besides innet accept data as commandline arguments (multiple entries split with a comma) or through stdin as multiline.

Bugs

Feel free to report issues, I build these tools simply because I couldn't find ones that did exactly this.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipwrangle-0.0.4.tar.gz (2.8 kB view details)

Uploaded Source

File details

Details for the file ipwrangle-0.0.4.tar.gz.

File metadata

  • Download URL: ipwrangle-0.0.4.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.7

File hashes

Hashes for ipwrangle-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ca13ee15d136141bbe6eaa8eb26a5dda7a9443488731f75b40ad00fc0f980b29
MD5 90bac7f27a0ba1e24a1fdcf008486cdf
BLAKE2b-256 91607c58a78b6eb6b5e6ddcd031134fedcd788dda42ab8678d53246f2c360802

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page