Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.2 KB

README.md

File metadata and controls

39 lines (30 loc) · 1.2 KB

cidr

CLI application for basic operations with CIDR blocks based on https://github.com/open-policy-agent/opa

Installation

Download the latest release for your platform from the releases page. Binaries are currently available for all combinations of [linux, darwin] and [amd64, arm64]. For darwin and arm64 this is:

wget https://github.com/rjuer/cidr/releases/latest/download/cidr-darwin-arm64 -O $HOME/bin/cidr && chmod +x $HOME/bin/cidr

You can download a specific version as well:

wget https://github.com/rjuer/cidr/releases/download/v0.2.3/cidr-darwin-arm64 -O $HOME/bin/cidr && chmod +x $HOME/bin/cidr

Usage

Currently, cidr can:

  • check if an IP address or CIDR block is contained in a particular CIDR block
  • expand a CIDR block to get all its IP addresses

To check if CIDR block 192.168.0.0/16 contains the IP address 192.168.7.42:

cidr contains 192.168.0.0/16 192.168.7.42

To check if CIDR block 192.168.0.0/16 contains the CIDR block 192.168.0.0/24:

cidr contains 192.168.0.0/16 192.168.0.0/24

To get all IP addressed within the CIDR block 192.168.0.0/24:

cidr expand 192.168.0.0/30