v1.1.0 Latest Release →

IP Range to Minimal CIDR
& Network Intelligence

High-performance, zero-dependency Go CLI and library for Site Reliability Engineers, cloud architects, and systems developers. Decompose arbitrary IPv4/IPv6 ranges into minimal CIDR blocks, detect collisions, carve subnets, and export directly for Terraform and AWS.

brew install smford/tap/cidr-calculator

⚡ Live Web Playground

Test CIDR decomposition and range intelligence directly in your browser. Real-time dual-stack calculations.

Quick samples:
FORMAT: CIDR 2 CIDR BLOCKS
192.168.1.10/31
192.168.1.12/30
Start IP
192.168.1.10
End IP
192.168.1.15
Total Addresses
6
Minimal Blocks
2

Engineered for Modern Cloud & Infra

Zero external Go runtime dependencies, fully tested with race detection, sub-millisecond execution.

📐

Minimal CIDR Decomposition

Computes the exact minimal set of power-of-two prefix blocks for any arbitrary contiguous range of IP addresses with mathematically optimal bitmasking.

🌐

Dual-Stack IPv4 & IPv6

First-class 128-bit math supports both standard IPv4 and IPv6 subnets, compressed hexadecimal addresses, and global unicast CIDRs.

🧩

CIDR Aggregation

Merges adjacent or overlapping CIDR blocks into their minimal superset (e.g. coalescing adjacent /24 subnets into /23s or /22s).

🛡️

Collision & Containment Detection

Detect IP address overlaps across VPCs and subnet allocations with exact intersection intervals. Returns clean non-zero exit codes for CI/CD gates.

✂️

Subnet Carving & Exclusion

Carve out reserved gateway IPs, DHCP pools, or Kubernetes node ranges from base subnets, returning the remaining optimal CIDR blocks.

☁️

Infrastructure-as-Code Native

Native presets for Terraform HCL lists (-format=terraform), AWS Security Group Ingress JSON rules (-format=aws), JSON, and CSV spreadsheets.

CLI Reference & Subcommands

Simple, Unix-philosophy command line interface designed for pipe-friendly shell workflows.

Base IP + Offset Convert base IP and count into minimal CIDRs
cidr-calculator 192.168.1.10+5
Terraform HCL Export Format directly as a Terraform list string for security groups or route tables
cidr-calculator -format=terraform 192.168.1.10+5
Aggregate Subnets (aggregate) Merge overlapping and contiguous CIDR blocks
cidr-calculator aggregate 10.0.0.0/24 10.0.1.0/24 10.0.0.128/25
Overlap Detection (overlap) Check for IP collision between two networks (exit code 1 if colliding)
cidr-calculator overlap 10.100.0.0/16 10.100.32.0/20
Subnet Containment (contains) Check if a supernet or VPC completely encapsulates a target range
cidr-calculator contains 10.0.0.0/16 10.0.5.1
Carve Exclusions (exclude) Subtract excluded IP ranges from a base subnet
cidr-calculator exclude 192.168.1.0/24 192.168.1.1 192.168.1.100-192.168.1.150
Split Subnet (split) Subdivide a parent network into smaller equal prefixes
cidr-calculator split 10.0.0.0/22 /24
Convert IP Formats (convert) Convert IPv4 between integer, hex, binary, and dotted quad
cidr-calculator convert 3232235786