Technical reference
Subnet Calculator technical details
This reference documents how the Subnet Calculator works: the input it accepts, the arithmetic behind each value, the special cases it follows, and where its address types and reverse zones come from.
The short answer
The Subnet Calculator takes one IPv4 or IPv6 address and a prefix length, then works out the network it belongs to with the same bitwise arithmetic a router uses. All of the arithmetic runs in your browser, and the calculator makes no network requests with the address. The result is kept in the page address as ?q=, for example /tools/subnet-calculator/?q=198.51.100.64/26, so opening, reloading or sharing that link sends the address and prefix to DNS Panopticon like any other page request. Avoid sharing links to sensitive internal addressing.
Clear the host bits and you have the network address; set them all and you have the last address in the block. Everything else on the page follows from those two numbers.
What you can enter
| Input | Example | How it is read |
|---|---|---|
| Address and prefix length | 192.0.2.10/24 | The usual CIDR form, for IPv4 or IPv6. |
| Address and subnet mask | 192.0.2.10 255.255.255.0 | IPv4 only. The mask must be contiguous: all its one bits first, then all zeros. |
| Address and wildcard mask | 192.0.2.10 0.0.0.255 | IPv4 only. An inverted mask, as written in router access lists, is recognised and the page says so. |
| A bare address | 2001:db8::1 | Assumed to be a /24 for IPv4 or a /64 for IPv6, and the page says so. |
| IPv6 with an embedded IPv4 address or zone | ::ffff:192.0.2.1, fe80::1%eth0 | The dotted part becomes the last 32 bits; a zone index after % is ignored. |
IPv4 octets with a leading zero, such as 010.0.0.1, are rejected rather than guessed at. The BSD inet_aton family of parsers reads a leading zero as octal, so 010 means 8 to some software and 10 to other software, a mismatch that has caused real access-control bypasses. IPv6 results are written in the canonical form from RFC 5952: lower case, no leading zeros in a group, and the longest run of zero groups shortened to ::.
How each value is worked out
| Value | Calculation |
|---|---|
| Subnet mask | Prefix-length one bits followed by zeros. A /26 is 26 ones and 6 zeros: 255.255.255.192. |
| Wildcard mask | The mask inverted, so ones over the host bits: 0.0.0.63 for a /26. |
| Network address | The address AND the mask. |
| Broadcast or last address | The network address OR the wildcard mask. |
| Addresses | 2 to the power of the host bits (32 or 128 minus the prefix length). |
| Usable hosts (IPv4) | Addresses minus 2 for prefixes up to /30, because the network and broadcast addresses are not assigned to hosts. A /31 has 2 usable addresses and a /32 has 1. |
| Historical class (IPv4) | From the first octet: A below 128, B below 192, C below 224, D (multicast) below 240, E above. Shown for reference only; routing has been classless since 1993. |
Addresses are held as arbitrary-precision integers, so a 128-bit IPv6 block is counted exactly, for example 18,446,744,073,709,551,616 addresses (2⁶⁴) in a /64, not rounded.
Special cases
- IPv4 /31. RFC 3021 allows a /31 on point-to-point links, with both addresses usable and no broadcast address. The calculator shows it that way.
- IPv4 /32 and IPv6 /128. A single address, used for loopbacks and host routes.
- IPv6 has no broadcast. The last address is not reserved for broadcast, so the page shows it as the last address. The total is the block’s mathematical address count: assigning hosts still has to allow for anycast and other special-purpose addresses and the link’s own addressing rules. The first address of each subnet is also the Subnet-Router anycast address defined in RFC 4291.
- IPv6 /127. RFC 6164 recommends a /127 between routers on point-to-point links.
- IPv6 longer than /64. Stateless address autoconfiguration (SLAAC) needs a 64-bit interface identifier, so the page notes that hosts on a longer prefix need static addresses or DHCPv6.
The visuals
- Network and host bits. Each bit of the address, mask, network and broadcast (or last) address is drawn as a cell: solid cells are network bits, dashed cells are host bits, and a bar marks the boundary. Octets (IPv4) or 16-bit hextets (IPv6) are labelled with their value. The same values are listed in a table below the picture for screen readers and copying.
- Address range. A bar shows the network address, the usable hosts and the broadcast address, with a pin where the address you typed falls.
- Where it sits. The block is shown among its neighbours inside a slightly larger block: back to the previous octet (IPv4) or hextet (IPv6) boundary when that is no more than 4 bits away, otherwise 4 bits up, so there are never more than 16 neighbours.
- Split into smaller subnets. Choose a prefix up to 16 bits longer. Up to 64 blocks are drawn and the first 256 are listed, each with a link that opens it. IPv6 blocks shorter than /64 split toward /64 by default, 8 bits at a time, so a /48 opens as 256 /56s.
Address types and reverse DNS
The address type comes from the IANA IPv4 and IPv6 Special-Purpose Address Registries (RFC 6890 and later updates), plus the RFC 1918 private ranges, multicast and the IPv6 global unicast range 2000::/3. The calculator reports the most specific registered range that holds the whole block. A block that is larger than a special range and contains it, such as 0.0.0.0/0, is labelled Mixed and the ranges inside it are named.
Reverse DNS names follow in-addr.arpa octet boundaries for IPv4 and ip6.arpa nibble (4-bit) boundaries for IPv6, as RFC 3596 defines. A block that does not end on a boundary spans several reverse zones: a /22 covers four /24 zones, and the page names the first and counts the rest. IPv4 blocks smaller than a /24 still live inside one /24 zone and are usually delegated with the CNAME technique in RFC 2317; see Reverse DNS and PTR Records.
Checking a device’s own settings
To compare the calculator with what a device is really using, these commands show each interface’s address and prefix length.
| Platform | Command | What it shows |
|---|---|---|
| Linux | ip -4 addr and ip -6 addr | Each address with its prefix length, as 198.51.100.77/26, and the IPv4 broadcast address. |
| Linux | ip route | The connected route the kernel built from the address and prefix. |
| Windows (PowerShell) | Get-NetIPAddress | Each address with its PrefixLength. |
| Windows (Command Prompt) | ipconfig | IPv4 address and subnet mask, and IPv6 addresses. |
| macOS | ifconfig | IPv4 addresses with a hex netmask such as 0xffffffc0 (a /26), and IPv6 addresses with prefixlen. |
FAQ
Is the address I type sent anywhere?
The calculation itself is not. The Subnet Calculator does all of its arithmetic in your browser and makes no network requests with the address. It does put the block in the page address as ?q=, so opening, reloading or sharing that link sends the address and prefix to DNS Panopticon like any other page request. Avoid sharing links to sensitive internal addressing.
Why does a /31 show two usable addresses?
RFC 3021 lets point-to-point links use a /31, where both addresses are assigned to the two ends and there is no broadcast address. Most modern routers support it, and it saves half the addresses a /30 would use.
Why is there no broadcast address for IPv6?
IPv6 has no broadcast. Traffic for every node on a link goes to multicast groups such as ff02::1 instead, so the last address is not reserved and the calculator shows it in place of a broadcast address. The address count is the block’s mathematical size; anycast and other reserved addresses still apply.
Why was my address with a leading zero rejected?
Some software reads an octet like 010 as octal (8) and other software as decimal (10). Rather than guess, the calculator asks for the address without leading zeros so the result matches what every system will see.
Sources and further reading
- RFC 4632: Classless Inter-domain Routing (CIDR)
- RFC 950: Internet Standard Subnetting Procedure
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links
- RFC 4291: IP Version 6 Addressing Architecture
- RFC 5952: A Recommendation for IPv6 Address Text Representation
- RFC 6164: Using 127-Bit IPv6 Prefixes on Inter-Router Links
- RFC 6890: Special-Purpose IP Address Registries
- IANA IPv4 Special-Purpose Address Registry
- IANA IPv6 Special-Purpose Address Registry
- RFC 3596: DNS Extensions to Support IP Version 6
- RFC 2317: Classless IN-ADDR.ARPA delegation