About

Tool No. 37 of Pikkola

A subnet is one number and a count of fixed bits. Everything else, the network address, the broadcast, the host range, the mask, is that pair rearranged. This page writes the rearrangement out, so the figures can be followed by hand rather than trusted.

What it does

The arithmetic, in three lines

Take the address as an integer. A prefix of p bits gives a mask with p ones followed by zeros. The network address is the address AND the mask; the broadcast is the network OR the complement of the mask; the number of addresses is two to the power of the bits that are left. For 192.168.10.0/24 that is 3232238080 AND 4294967040, which is 3232238080, and 3232238080 OR 255, which is 3232238335, or 192.168.10.255.

IPv4 is held as one 32-bit integer and IPv6 as one 128-bit integer. JavaScript numbers lose precision above 2^53, so both are kept in BigInt and every split, count and comparison is done on exact integers. That is why the page can tell you that a /64 holds 18,446,744,073,709,551,616 addresses without rounding.

A mask written in dotted form has to be contiguous ones and then zeros, otherwise it does not describe a single prefix. A wildcard mask is the complement of that mask. This page accepts either in the mask field and shows the other two spellings, and it refuses a dotted mask with a hole in it instead of picking something close.

The two ends

In IPv4 the lowest address of a block names the subnet and the highest is the broadcast, so a /24 has 254 usable hosts. There are two exceptions. A /31 is a point-to-point link under RFC 3021 and both addresses are usable. A /32 is a single host. IPv6 has no broadcast at all: every address in the block can belong to an interface, and the all-zero host part is reserved as the subnet-router anycast address. The page says which case it is applying under the usable count.

The label on a block

Whether a block is private is a property of the range, not of the address: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are RFC 1918; 100.64.0.0/10 is the shared space carriers use for CGNAT; 127.0.0.0/8 is loopback; 169.254.0.0/16 is link-local. IPv6 has its own list, including fc00::/7 for unique local addresses and fe80::/10 for link-local. The page tests the block against each range and says when a block only partly covers one.

What it deliberately does not do

Why it is free

Pikkola builds small tools that do one job and keeps them free, with no account and no advertising. A static page that does arithmetic in the browser costs almost nothing to serve, so there is no reason to charge for it.

Contact

A block that reads wrong, a phrase that reads badly in Korean or Japanese, a range that should be in the list and is not: hello@pikkola.com. Send the block and what you expected to see.

Back to the calculator