A subnet calculator converts a CIDR prefix, such as /24, into its subnet mask and identifies the network, usable host range, and broadcast address for an IPv4 subnet. Enter an IPv4 address and prefix length; the results show how the address space is divided, with a note about special cases such as /31 and /32.
Formula
This calculator uses an integer form of the IPv4 subnet calculation. IPv4 addresses contain 32 bits. A prefix length p marks the first p bits as the network portion; the remaining 32 − p bits identify addresses within that subnet.
- Block size: B = 232 − p addresses.
- Network address: N = floor(A / B) × B.
- Broadcast address: Q = N + B − 1.
- Conventional usable host count: H = max(0, B − 2).
- Network mask: the 32-bit value with p leading 1 bits and 32 − p trailing 0 bits.
A is the supplied IPv4 address represented as an unsigned integer from 0 through 4,294,967,295. p is the prefix length, from 0 through 32. N, Q, and the mask are also represented as integers in the calculator specification; a normal subnet tool displays them in dotted-decimal notation. The host count follows the usual rule of excluding the network and broadcast addresses. That convention needs adjustment for /31 point-to-point links and /32 single-address routes.
Worked Example
The defaults represent 192.168.1.1/24. The dotted address becomes A = 3,232,235,777, and p = 24.
- There are 32 − 24 = 8 host bits, so B = 28 = 256 addresses.
- N = floor(3,232,235,777 / 256) × 256 = 3,232,235,776, which is 192.168.1.0.
- Q = 3,232,235,776 + 256 − 1 = 3,232,236,031, which is 192.168.1.255.
- The mask has 24 leading one bits: 255.255.255.0, or 4,294,967,295 as an integer.
- H = 256 − 2 = 254 conventional usable host addresses, from 192.168.1.1 through 192.168.1.254.
In everyday use, enter the address and prefix in dotted form in a subnet calculator; the integer representation above is only the calculation model. This example’s address is itself the first usable address, so it is also the network range’s lower host endpoint.
How CIDR Becomes a Network Mask
CIDR, short for Classless Inter-Domain Routing, writes a prefix length after a slash. The /24 in 192.168.1.1/24 means 24 of the address’s 32 bits belong to the network prefix. Turning those bits on and the remaining bits off gives the subnet mask.
For example, /24 corresponds to 255.255.255.0. A less familiar prefix, /26, corresponds to 255.255.255.192. The last octet is 192 because its first two bits are on (128 + 64), while the other six are off. A dotted mask is not just any sequence of numbers: its binary form must consist of consecutive 1s followed by consecutive 0s.
The prefix also determines the size of the address block. A /26 has 32 − 26 = 6 host bits, so it contains 64 addresses. Subnets begin on block boundaries: within a /24, the four /26 ranges are .0–.63, .64–.127, .128–.191, and .192–.255.
Reading the Host Range and Special Cases
For a conventional IPv4 subnet with at least two host bits, the network address identifies the subnet and the broadcast address reaches all hosts on that subnet. The usable range is normally one address after the network address through one before the broadcast address.
For 192.168.1.70/26, the block size is 64. The address falls in the .64–.127 block, so the network is 192.168.1.64, the broadcast address is 192.168.1.127, and the conventional host range is 192.168.1.65–192.168.1.126. There are 62 conventional host addresses.
Do not apply the “subtract two” rule blindly. A /31 has two addresses and is commonly used on point-to-point links, where both can serve as endpoints under the applicable networking conventions. A /32 identifies one address, often used for a host route; it has no range of other addresses. A /0 covers the entire IPv4 address space, but that does not make every address an assignable host. The calculator’s conventional count is a mathematical convention, not a guarantee that an address is available or appropriate on a particular network.
When to Use a Subnet Calculator
A subnet calculator is useful when planning a network, checking a configuration, interpreting a routing table, or confirming which addresses belong to a subnet. It can quickly catch a mismatch between an address and its intended prefix, and show how a larger block can be split into smaller ones.
- Use the network address to identify the subnet after normalizing an address to its prefix.
- Use the mask when a device or form asks for a dotted-decimal subnet mask instead of CIDR notation.
- Use the host range and count to understand the address capacity, while checking reserved or already assigned addresses separately.
- Use the broadcast address to understand the subnet boundary; it is not normally assigned to an individual host.
For subnet design, first estimate the number of devices or interfaces that need addresses, then choose a prefix with enough space and account for network conventions. A calculator can verify the arithmetic, but it cannot know your organization’s address plan, routing policy, reservations, or whether a block overlaps another network.
Common Mistakes and Limits
A frequent error is treating the address entered as the network address. For example, 192.168.1.70/26 is a host address in the 192.168.1.64/26 network, not the network address itself. The calculator rounds the address down to the correct block boundary.
- Forgetting the prefix: an IP address alone does not determine its subnet. The same address can belong to differently sized subnets depending on the prefix.
- Mixing address count with usable hosts: a /26 contains 64 total addresses but conventionally 62 usable host addresses.
- Assuming every block ends on familiar octets: prefixes such as /25, /26, and /27 divide an octet into smaller ranges.
- Confusing IPv4 and IPv6: this calculation covers 32-bit IPv4 only. IPv6 uses 128-bit addresses and different display and operational conventions.
- Relying on rounding: network boundaries are exact. A calculator should not round a prefix or address to make an invalid input appear valid.
Results describe address arithmetic, not reachability. Firewalls, routing, duplicate assignments, and network configuration can affect whether a device can communicate even when its address is mathematically inside the range.
Frequently Asked Questions
Does /24 always mean 255.255.255.0?
Yes. In IPv4, /24 means 24 leading mask bits are 1, which gives 255.255.255.0. The complete subnet still depends on the IP address paired with that prefix.
How do I find the usable host range?
For a conventional subnet larger than /31, find the network and broadcast addresses, then use the addresses between them. For example, 10.0.0.8/29 has network .8, broadcast .15, and usable range .9–.14.
Why are two addresses subtracted from the total?
In the conventional IPv4 subnet model, one address identifies the subnet and one is its directed broadcast address. The rule is not appropriate for every special-purpose prefix, including common /31 point-to-point links and /32 routes.
Can I calculate a subnet from an IP address without a prefix?
No. The address does not specify how many bits identify the network. You need a prefix length or an equivalent subnet mask to calculate the network and range.
Is a subnet mask the same as a CIDR prefix?
They express the same boundary in different forms. A prefix such as /26 states the number of network bits; the equivalent mask is 255.255.255.192.
Related
Formula used
in ip | IPv4 address as integer | - | 3232235777 | 0 | 4294967295 in p | CIDR prefix length | bits | 24 | 0 | 32 out mask | Network mask as integer | - | 4294967295 - floor(4294967296 / 2^p) | 0 out network | Network address as integer | - | floor(ip / (4294967296 / 2^p)) * (4294967296 / 2^p) | 0 out broadcast | Broadcast address as integer | - | floor(ip / (4294967296 / 2^p)) * (4294967296 / 2^p) + (4294967296 / 2^p) - 1 | 0 out hosts | Conventional usable IPv4 host addresses | addresses | max(0, 2^(32-p) - 2) | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Delete Picture Kik? How to Remove Photos
- Data Breaches That Shook the World
- Disable Google Assistant: Turn It Off on Android & Home
- Resin vs FDM Printers for Miniatures: Detail, Durability, Cost
- Are Networked Implants Safe? What If One Fails?
- How to Stop WordPress Comment Spam: A Layered Guide