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 \
    -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

This also works for IPv6 addresses, for example:

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

Check for CIDR range overlaps

To check if two CIDR ranges overlap you can do:

$ cidrchk overlaps

Generate IPs from CIDR range

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

$ cidrchk expand | jq .
  "cidr": "",
  "ips": [

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

$ cidrchk expand | jq '.ips[] | length'