calculateCIDR
Fast CIDR network calculator for the terminal: IPv4 & IPv6, subnet division, address classification, binary view and JSON output for scripts.
✨ Features
- 🌐 IPv4 & IPv6 — network ID, host range, broadcast, netmask, wildcard and host count
- 🎯 Any address works —
10.1.2.3/20shows the address and the network it belongs to - 🧩 Subnet division — split any network into N subnets with correct prefix math
- 🏷️ Address type — Private (RFC 1918), Public, CGNAT, Loopback, Link-local, Multicast, Documentation…
- 📐 RFC 3021 aware —
/31point-to-point links have 2 usable hosts,/32has 1 - 🔠 Binary display — every IPv4 field in binary octets
- 🤖 JSON output — pipe results into
jq, Ansible or your own scripts - 🔇 Script-friendly — plain output when piped or when
NO_COLORis set; errors go to stderr
📥 Installation
pip install cidr-calculator
Or from source:
git clone https://github.com/serber-info/calculateCIDR.git
cd calculateCIDR
pip install -e .
🛠 Usage
cidr IP/PREFIX [-divide N] [-binary] [--json]
| Option | Description |
|---|---|
IP/PREFIX |
Address with CIDR prefix (-ip IP/PREFIX also works) |
-divide N |
Split the network into N subnets |
-binary |
Show IPv4 addresses in binary |
-j, --json |
Machine-readable JSON output |
-v, --version |
Show version |
-h, --help |
Show help |
🎨 Examples
Network details
cidr 192.168.1.10/24
╔══════════════════════════════════════════════╗
║ 192.168.1.0/24 · IPv4 ║
╚══════════════════════════════════════════════╝
Address 192.168.1.10
Network ID 192.168.1.0
First Host 192.168.1.1
Last Host 192.168.1.254
Broadcast 192.168.1.255
Netmask 255.255.255.0
Wildcard 0.0.0.255
Prefix /24
Hosts 254
Type Private (RFC 1918)
Subnet division
cidr 192.168.1.0/24 -divide 4
╔════════════════════════════════════════════════════╗
║ 192.168.1.0/24 · 4 subnets / new prefix /26 ║
╚════════════════════════════════════════════════════╝
# Subnet Network ID First Host Last Host Broadcast Netmask Wildcard Hosts
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 192.168.1.0/26 192.168.1.0 192.168.1.1 192.168.1.62 192.168.1.63 255.255.255.192 0.0.0.63 62
2 192.168.1.64/26 192.168.1.64 192.168.1.65 192.168.1.126 192.168.1.127 255.255.255.192 0.0.0.63 62
3 192.168.1.128/26 192.168.1.128 192.168.1.129 192.168.1.190 192.168.1.191 255.255.255.192 0.0.0.63 62
4 192.168.1.192/26 192.168.1.192 192.168.1.193 192.168.1.254 192.168.1.255 255.255.255.192 0.0.0.63 62
When N is not a power of two, the next power is used and the first N subnets are shown.
JSON for scripts
cidr 10.0.0.0/30 --json
{
"input": "10.0.0.0/30",
"address": "10.0.0.0",
"network": "10.0.0.0/30",
"version": 4,
"network_id": "10.0.0.0",
"broadcast": "10.0.0.3",
"netmask": "255.255.255.252",
"wildcard": "0.0.0.3",
"prefix": 30,
"first_host": "10.0.0.1",
"last_host": "10.0.0.2",
"usable_hosts": 2,
"total_addresses": 4,
"type": "Private (RFC 1918)"
}
# Usable hosts of a network, straight into a variable
hosts=$(cidr 10.20.0.0/22 --json | jq .usable_hosts)
Binary and IPv6
cidr 192.168.1.0/24 -binary
cidr 2001:db8::/32 -divide 16
🧪 Development
pip install -e ".[dev]"
ruff check .
pytest
See CHANGELOG.md for release notes.
📝 License
MIT — see LICENSE.
💬 Feedback
Open an issue or reach out via GitHub.
🌐 Connect
Metadata
Release files for cidr-calculator 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cidr_calculator-2.1.1.tar.gz | 9.4 kB | Without provenance | Details for cidr_calculator-2.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cidr_calculator-2.1.1-py3-none-any.whl | Python 3 | none | any | Details for cidr_calculator-2.1.1-py3-none-any.whl |
Total release size: 17.9 kB
Release files / cidr_calculator-2.1.1.tar.gz
| Download URL | cidr_calculator-2.1.1.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
50c7ee7d782f767066f40c4c6db1a2fc5e85a8d32fe28c87cfec4d2491ad2ec6
|
|
BLAKE2b-256 checksum How to use checksums |
797041d4d11f1a89d1cfb103674178017cf4a3c5cd8caafad4bc269f1997805a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / cidr_calculator-2.1.1-py3-none-any.whl
| Download URL | cidr_calculator-2.1.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc1a1d5cf2c9d485f843ee4045a92560cc48d4e898ba8683358c2979c061ecdf
|
|
BLAKE2b-256 checksum How to use checksums |
8ad03a5c71cf2e23b6cd5cd575dffd7ea3b1276de2d7ee19b4080e2f8ae2609b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for cidr-calculator 2.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.