Subnet Calculator
Netmask, CIDR prefix, network and broadcast address, and usable host range — worked out in binary, step by step
An IP Address Is 32 Bits
An IPv4 address is a 32-bit unsigned integer, written as four 8-bit octets in decimal. Every subnetting question is a question about those 32 bits, so the first move is always to convert to binary using the octet place values :
| Decimal | Binary |
|---|---|
| 192 | 11000000 |
| 168 | 10101000 |
| 10 | 00001010 |
| 130 | 10000010 |
So 192.168.10.130 is 11000000.10101000.00001010.10000010.
A prefix length means the mask is consecutive 1 bits followed by zero bits. The 1 bits mark the network portion, the 0 bits the host portion:
/24→11111111.11111111.11111111.00000000=255.255.255.0/26→11111111.11111111.11111111.11000000=255.255.255.192
Going the other way, convert each mask octet to binary and count the ones: is eight ones and is 11111110, seven ones, so 255.255.254.0 is /23.
The condition people forget: a valid mask is contiguous ones followed by zeros. 255.255.255.192 is legal because 11000000. 255.255.255.160 is not, because 10100000 — its ones are separated by a zero.
Network and Broadcast by Bitwise AND
Network address
AND the address with the mask, bit by bit (, everything else ). Octets masked by 255 pass through unchanged, so only the boundary octet does real work. For 192.168.10.130/26:
130 = 1 0 0 0 0 0 1 0
192 = 1 1 0 0 0 0 0 0 (mask)
AND = 1 0 0 0 0 0 0 0 = 128
Network = 192.168.10.128.
Broadcast address
Keep the network bits, set every host bit to 1: 10000000 → 10111111 , so the broadcast is 192.168.10.191.
Host count
With host bits:
The removes the network address (all host bits 0) and the broadcast (all host bits 1). A /26 has : addresses, usable.
Block size shortcut
, so /26 subnets start every 64 addresses: .0, .64, .128, .192. To size a subnet instead, find the smallest with and take .
Common Mistakes to Avoid
- Assuming the given address is the network address.
192.168.10.130/26is a host inside192.168.10.128/26. Always AND first. - Subtracting 2 where it does not apply. A
/31point-to-point link (RFC 3021) gives 2 usable addresses, and a/32is a single host route. - Off-by-one on the broadcast. Broadcast network block size , not network block size.
- Reading the prefix backwards. A larger means a smaller network:
/26holds a quarter of what/24holds. - Non-contiguous masks. Only masks of the form ones-then-zeros are valid, which is why the mask octet is always one of 0, 128, 192, 224, 240, 248, 252, 254, 255.
- Carrying IPv4 habits into IPv6. IPv6 has no broadcast address and no rule; a
/64simply holds addresses.
Examples
255.255.255.19210000010, mask 1100000010000010 11000000 10000000 , so the network is 192.168.10.12810111111 , so the broadcast is 192.168.10.191192.168.10.128, broadcast 192.168.10.191, usable range 192.168.10.129–192.168.10.190, 62 usable hosts11111111, 11111111, 11111110, 00000000/23/23 spans two full third-octet blocks — addresses255.255.254.0 = /23, 512 addresses, 510 usable hosts11111111.11111111.11111111.10000000 255.255.255.128/25 subnets of 10.0.5.0/24 start at .0 and .12810.0.5.128, host bits all 1 → 11111111 , broadcast 10.0.5.25510.0.5.129–10.0.5.254, which is addresses — 26 spare/25 (255.255.255.128), 126 usable hosts; the second subnet is 10.0.5.128/25, range 10.0.5.129–10.0.5.254Frequently Asked Questions
Convert both to binary and take the bitwise AND, one bit at a time. Octets where the mask is 255 pass through unchanged, so in practice only the octet that the prefix splits needs working out. For 192.168.10.130/26 the fourth octet is 10000010 AND 11000000 = 10000000 = 128, giving the network 192.168.10.128.
A /26 leaves 32 − 26 = 6 host bits, so 2^6 = 64 addresses. Two are reserved — the all-zeros network address and the all-ones broadcast address — leaving 62 usable host addresses.
Write each mask octet in binary and count the leading 1 bits. 255.255.255.0 is 8 + 8 + 8 = /24, and 255.255.254.0 is 8 + 8 + 7 = /23. Only masks made of contiguous ones followed by zeros are valid, so each octet must be one of 0, 128, 192, 224, 240, 248, 252, 254 or 255.
The −2 exists because the all-zeros and all-ones addresses are reserved for the network and broadcast. A /32 is a single-address host route, and RFC 3021 allows a /31 to be used on point-to-point links where no broadcast is needed, so both of its addresses are usable.
Try AI-Math for Free
Get step-by-step solutions to any math problem. Upload a photo or type your question.
Start Solving