A beautiful command-line tool for parsing CIDR subnet masks and checking IP address membership, built with Go.
-
Parse CIDR Notation - Display comprehensive network information including:
- Network address and subnet mask
- Broadcast address
- IP range (total and usable)
- Host counts (total and usable)
-
IP Membership Checking - Verify if an IP address belongs to one or more CIDR ranges
-
Config File Support - Load default CIDR ranges from
~/.cidrfile -
Beautiful Output - Color-coded terminal output with clear visual hierarchy using Lipgloss
go install github.com/trahma/cidr@latestOr build from source:
git clone https://github.com/trahma/cidr
cd cidr
go build -o cidr .After installing with go install, you need to ensure GOPATH/bin is in your PATH.
echo $PATH | grep -q "$(go env GOPATH)/bin" && echo "✓ Already in PATH" || echo "✗ Not in PATH"If not already in PATH, add it to your shell configuration:
Bash (~/.bashrc):
echo 'export PATH="$PATH:$(go env GOPATH)/bin"' >> ~/.bashrc
source ~/.bashrcZsh (~/.zshrc):
echo 'export PATH="$PATH:$(go env GOPATH)/bin"' >> ~/.zshrc
source ~/.zshrcFish (~/.config/fish/config.fish):
fish_add_path (go env GOPATH)/bincidr --helpIf you see the help output, you're all set!
cidr 192.168.1.0/24Output:
CIDR Information
CIDR: 192.168.1.0/24
Network Address: 192.168.1.0
Subnet Mask: 255.255.255.0
Broadcast Address: 192.168.1.255
IP Range: 192.168.1.0 - 192.168.1.255
Usable IPs: 192.168.1.1 - 192.168.1.254
Total Hosts: 256
Usable Hosts: 254
cidr 192.168.1.0/24 --check 192.168.1.50cidr --check 192.168.5.10This will check the IP against all CIDR ranges defined in your ~/.cidr config file.
Create a ~/.cidr file with your default CIDR ranges (one per line):
# Private network ranges
192.168.0.0/16
10.0.0.0/8
172.16.0.0/12
Lines starting with # are treated as comments and ignored.
You can also specify a custom config file:
cidr --config /path/to/custom.cidr --check 192.168.1.1Flags:
-c, --check string Check if an IP address is within the CIDR range
-f, --config string Path to .cidr config file (defaults to ~/.cidr)
-h, --help help for cidr
Parse a large network:
cidr 10.0.0.0/8Check an IP against multiple ranges:
cidr --check 172.16.5.100Parse with custom config file:
cidr --config ./networks.cidr --check 192.168.1.1MIT