CLI tool for CIDR range operations (check, generate)

Overview

cidrchk

release

A CLI tool to assist you with CIDR ranges and IPs.

Install it

You can download the latest binary for Linux (Intel and Arm), macOS, and Windows.

For example, to install cidrchk from binary on macOS, do the following:

curl -L https://github.com/mhausenblas/cidrchk/releases/latest/download/cidrchk_darwin_amd64.tar.gz \
    -o cidrchk.tar.gz && \
    tar xvzf cidrchk.tar.gz cidrchk && \
    mv cidrchk /usr/local/bin && \
    rm cidrchk*

Use it

cidrchk can do three things for you: 1. check CIDR ranges for inclusion, 2. check for CIDR range overlaps, and 3. generate all IPs in a CIDR range.

Note that cidrchk uses OPA Rego to perform CIDR operation, to be precise the built-in Net functions.

Check for CIDR range inclusion

To check if a CIDR range contains an IP or another CIDR range:

$ cidrchk contains 192.168.0.0/16 192.168.0.42
yes

This also works for IPv6 addresses, for example:

$ cidrchk contains \
          0:0:0:0:0:ffff:c0a8:0/30 \
          0:3:ffff:ffff:ffff:ffff:ffff:ffff
yes

Check for CIDR range overlaps

To check if two CIDR ranges overlap you can do:

$ cidrchk overlaps 192.168.0.0/16 192.168.1.0/24
yes

Generate IPs from CIDR range

To expand a CIDR range, that is, to generate all IPs in it do the following:

$ cidrchk expand 192.168.0.0/30 | jq .
{
  "cidr": "192.168.0.0/30",
  "ips": [
    [
      "192.168.0.0",
      "192.168.0.1",
      "192.168.0.2",
      "192.168.0.3"
    ]
  ]
}

One can also answer questions like "How many IP addresses are there in a CIDR range", for example:

$ cidrchk expand 192.168.0.0/16 | jq '.ips[] | length'
65536
You might also like...
Generate Changelogs from Commits (CLI)

Commitlog Changelog generator using Commit History To see an example of this in action, you can check the actions file for this repo. Yes it uses itse

A simple CLI applet to generate 'White Noise' pictorial depictions.
A simple CLI applet to generate 'White Noise' pictorial depictions.

White Noise Generator A simple CLI applet written in Go to create pictorial representations of White Noise. Example Okay, but how? An output file of t

Easy to use library and CLI utility to generate Go struct from CSV files.

csv2struct Easy to use library and CLI utility to generate Go struct from CSV files. As a benefit, it's fully compatible with csvutil. So, structs gen

Powerful CLI written in GO to generate projects in various technologies
Powerful CLI written in GO to generate projects in various technologies

Barca CLI is a project generator written in GO and its purpose is to build and configure HTTP servers, web proxy, SPA/PWA, Blog and custom landing page. It's easy, fast and productive.

Show Languages In Code. A fast and lightweight CLI to generate stats on the languages inside your project
Show Languages In Code. A fast and lightweight CLI to generate stats on the languages inside your project

slic Show Languages In Code. Usage Run it with an -h flag to list all commands. -d flag can be used to specify the directory of search -i flag can be

Generate an interactive, autocompleting shell for any Cobra CLI
Generate an interactive, autocompleting shell for any Cobra CLI

cobra-shell Description Leverages the Cobra completion API to generate an interactive shell for any Cobra CLI, powered by go-prompt. On-the-fly autoco

A GitHub CLI extension to view and generate license files.

gh-license A GitHub CLI extension to view and generate license files. All license information is obtained from the GitHub API. NOTE: The only purpose

Script to check open slot for 18+ age group in particular district and pin code area

Running instruction install go: 1.14 (might work with other versions as well) install following library for sending notifications go get -u github.com

check if new episodes of anime has been released from you're terminal
check if new episodes of anime has been released from you're terminal

checkanime Check if new episodes of you're favourite anime has been released from you're terminal Installation Make sure $GOPATH/bin is added to PATH

Comments
  • Exit with a return code for commands that return a boolean

    Exit with a return code for commands that return a boolean

    This return code indicates whether the command returned a "no" with a nonzero return code so you can use cidrchk in shell constructs like if and &&. This change also returns a return code of 1 when the user's command isn't found.

    opened by delucks 5
Releases(v0.5)
Owner
Michael Hausenblas
Michael Hausenblas
Github-org-diff - Simple CLI tool to check a diff between 2 branches of all org repos

github-org-diff Simple CLI tool to list org repos that have diff between dev and

Alex Pliutau 1 Jan 25, 2022
cross-platform, cli app to perform various operations on string

sttr is command line software that allows you to quickly run various transformation operations on the string.

Abhimanyu Sharma 419 Sep 22, 2022
Vaku is a CLI and API for running path- and folder-based operations on the Vault Key/Value secrets engine.

Vaku Vaku is a CLI and API for running path- and folder-based operations on the Vault Key/Value secrets engine. Vaku extends the existing Vault CLI an

Sean Lingren 138 Aug 3, 2022
The blackbean is a command tool for elasticsearch operations by using cobra.

The blackbean is a command tool for elasticsearch operations by using cobra. Besides, blackbean is the name of my lovely French bulldog.

null 23 Mar 3, 2022
A CLI Tool to easily generate your Terraform configuration

Tf Tf is a command line tool to easily generate your Terraform configuration with an interactive prompt. Inspiration Boredom in Covid-19 Installation

Gowtham Munukutla 19 Jul 26, 2022
A tool to manage all your boilerplate from cli and generate files for you !

A tool to manage all your boilerplate from cli and generate files for you !

null 28 Jul 20, 2022
Cobra CLI tool to generate applications and commands

Cobra Generator Cobra provides its own program that will create your application and add any commands you want. It's the easiest way to incorporate Co

Steve Francia 206 Sep 22, 2022
sttr is command line software that allows you to quickly run various transformation operations on the string.

sttr is command line software that allows you to quickly run various transformation operations on the string.

Abhimanyu Sharma 60 Sep 21, 2021
A TUI multitool for day-to-day operations for software applications.

Bench (WIP) A TUI multitool for day-to-day operations for software applications. Lets you do common operations needed during IT work that are common e

null 1 Dec 5, 2021
Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Nebula Diagnosis CLI Tool is an information diagnosis cli tool for the nebula service and the node to which the service belongs.

Katz 1 Jan 12, 2022