Home › Developer & IT › IP Subnet Calculator
IP Subnet Calculator
Computes the network and broadcast addresses, subnet and wildcard masks, first and last host, usable and total addresses, address class and RFC 1918 private status for an IPv4 address in CIDR notation or with a dotted subnet mask, using 32-bit unsigned arithmetic.
When to use
You need to know which subnet an IPv4 address belongs to, the host range and count of a /prefix, or the mask equivalent of a prefix length.
Do not use when: The address is IPv6, you want to split a block into several subnets (VLSM planning), or you only need a number in binary or hex (use base-converter).
Formula
mask = 2^32 − 2^(32 − prefix); network = ip AND mask; broadcast = network OR NOT mask; total = 2^(32 − prefix); usable = total − 2 (prefix ≤ 30), 2 (prefix 31), 1 (prefix 32)
Classless (CIDR, RFC 4632) arithmetic on 32-bit unsigned integers; /31 follows RFC 3021 (both addresses usable on point-to-point links). Class letters are the historical classful designations only.
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
cidr | string | yes | IPv4 address followed by /prefix (0–32) or by a dotted subnet mask separated by a space or slash, e.g. 192.168.1.10/26 or 192.168.1.10 255.255.255.192. |
Outputs
| Output | Type | Unit | Description |
|---|---|---|---|
ip_address | string | The address as parsed (dotted quad). | |
cidr_notation | string | Network address with prefix length, e.g. 192.168.1.0/26. | |
network_address | string | ip AND mask: the first address of the block. | |
broadcast_address | string | network OR wildcard: the last address of the block (equals the address itself for /32). | |
subnet_mask | string | Dotted-decimal mask with prefix_length leading one bits. | |
wildcard_mask | string | Bitwise complement of the subnet mask (used in Cisco ACLs). | |
prefix_length | integer | bits | Number of network bits (the /n). |
host_bits | integer | bits | 32 − prefix_length. |
first_host | string | network + 1 (for /31 and /32 the network address itself, RFC 3021). | |
last_host | string | broadcast − 1 (for /31 the second address, for /32 the address itself). | |
usable_hosts | integer | 2^host_bits − 2, except 2 for /31 (RFC 3021 point-to-point) and 1 for /32. | |
total_addresses | integer | 2^host_bits including network and broadcast. | |
ip_class | string | Historical classful class from the first octet: A (0–127), B (128–191), C (192–223), D (224–239, multicast), E (240–255, reserved). | |
is_private | boolean | true when the address lies in 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16; loopback and link-local blocks are reported separately in address_scope. | |
address_scope | string | Special-use block the address belongs to (RFC 1918 private, loopback, link-local, CGNAT, multicast, reserved) or public. | |
binary_mask | string | Subnet mask as four 8-bit groups. | |
binary_address | string | The IP address as four 8-bit groups. | |
ip_integer | integer | The address as an unsigned 32-bit integer (a·2^24 + b·2^16 + c·2^8 + d). |
Example
192.168.1.10/26: {"cidr":"192.168.1.10/26"} → {"network_address":"192.168.1.0","broadcast_address":"192.168.1.63","subnet_mask":"255.255.255.192","wildcard_mask":"0.0.0.63","first_host":"192.168.1.1","last_host":"192.168.1.62","usable_hosts":62,"total_addresses":64,"prefix_length":26,"ip_class":"C","is_private":true,"ip_integer":3232235786,"binary_mask":"11111111.11111111.11111111.11000000"}
10.0.0.0/8 (whole class A private block): {"cidr":"10.0.0.0 255.0.0.0"} → {"network_address":"10.0.0.0","broadcast_address":"10.255.255.255","usable_hosts":16777214,"total_addresses":16777216,"prefix_length":8,"first_host":"10.0.0.1","last_host":"10.255.255.254","ip_class":"A"}
GET https://tttkmbb.com/api/v1/calculate/subnet-calculator?cidr=192.168.1.10%2F26
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/subnet-calculator(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/subnet-calculator · Markdown: https://tttkmbb.com/developer/subnet-calculator.md · JSON definition: https://tttkmbb.com/developer/subnet-calculator.json
- MCP: server
https://tttkmbb.com/mcp, toolcalculate_subnet - OpenAPI operationId:
calculate_subnet - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
FAQ
Why does a /31 report 2 usable hosts?
RFC 3021 allows both addresses of a /31 on point-to-point links, since no broadcast address is needed; a /32 is a single host route. Every other prefix loses the network and broadcast addresses.
Can I enter the mask instead of the prefix?
Yes: 192.168.1.10 255.255.255.192 and 192.168.1.10/255.255.255.192 are both accepted. The mask must be contiguous ones followed by zeros.
Does is_private cover loopback and link-local addresses?
No, is_private is strictly RFC 1918; 127.0.0.0/8 (loopback), 169.254.0.0/16 (link-local) and 100.64.0.0/10 (carrier-grade NAT) are named in address_scope instead.
Related calculators
- Number Base Converter — Convert an octet or the whole address between binary, decimal and hexadecimal.
- Bitwise Operations Calculator — AND/OR/NOT on 32-bit values is exactly what subnet masking does.
- Bandwidth-Delay Product Calculator — Another network-engineering calculation: TCP window size for a link.