Cidrspan

The method

A prefix is a bit boundary

IPv4 addresses contain 32 bits, conventionally shown as four decimal octets. CIDR notation places a slash and a prefix length after the address. That length, from 0 to 32, states how many leading bits belong to the prefix. The remaining bits determine the numerical size of its aligned block.

From an entered address to its block

For octets a, b, c and d, convert the address to the integer A = 16777216a + 65536b + 256c + d. If the prefix length is p, let S = 2^(32 − p). The lowest address is N = floor(A / S) × S. The highest is N + S − 1. The complete inclusive count is S, and the entered address has zero-based offset A − N.

The prefix mask is (2^32 − 1) − (S − 1). Its inverse wildcard is S − 1. The script uses exact BigInt arithmetic so an address above 2^31 never becomes a negative signed bitwise value. All counts, including 4,294,967,296 for /0, remain exact. There is no address-by-address enumeration.

A worked /27 example

For 198.51.100.206/27, five bits remain after the prefix, so the block size is 32. The last octet belongs to the group starting at 192. The canonical block is 198.51.100.192/27, its numerical upper endpoint is 198.51.100.223, and the entered address has offset 14. The mask is 255.255.255.224, with inverse wildcard 0.0.0.31.

Endpoints are numerical boundaries

The full count is not a universal usable-host capacity. Network and broadcast behavior depends on the network context. In particular, RFC 3021 describes the two addresses of a /31 point-to-point link as host addresses. Subtracting two from every block would therefore give misleading results. This tool consistently labels the lowest and highest numerical addresses and reports the complete mathematical count.

A /32 contains one address, with identical endpoints and offset zero. A /0 contains the entire 32-bit numerical range. Neither result establishes reachability, permission to use an address, a routing configuration or a current allocation. The tool does not make a private/global classification or a deployment recommendation.

Accepted syntax

Enter exactly four ASCII decimal octets from 0 to 255, a slash, and a prefix from 0 to 32. Leading zeroes are rejected except for the single digit 0. Optional outer ASCII spaces, tabs, CR and LF are trimmed; interior whitespace is rejected. Raw input is limited to 64 UTF-16 code units. IPv6, hostnames, URLs, shortened addresses, hex, exponent notation and dotted input masks are unsupported.

Sources

RFC 791 supports the four-octet width. RFC 4632, section 3.1 describes classless prefix notation and block sizes. RFC 3021 explains the /31 point-to-point exception. RFC 5737 supplies documentation ranges used in the examples. These sources support the model; this page makes no current routing or allocation lookup.