IPv4 Subnetting Explained: Masks, Prefixes, Network and Broadcast Addresses
A subnet divides an IP network into smaller blocks. A subnet calculator takes an address and a prefix length and tells you the network address, mask, broadcast address and usable hosts. This guide shows how those numbers arise.
How an IPv4 address and prefix work
An IPv4 address is 32 bits, written as four decimal numbers from 0 to 255. The prefix length (for example /24) says how many of the leading bits identify the network; the rest identify hosts within it. The subnet mask is the same idea written out: /24 is 255.255.255.0, where 24 ones are followed by 8 zeros.
Worked example: 192.168.1.130/26
A /26 mask has 26 network bits, so the host part is 6 bits, giving blocks of 26 = 64 addresses. Mask: 255.255.255.192. The block boundaries in the last octet are 0, 64, 128 and 192. The address .130 falls in the block starting at 128, so the network is 192.168.1.128/26, the broadcast address is 192.168.1.191, and usable hosts run from 192.168.1.129 to 192.168.1.190: 62 usable hosts.
Usable hosts
Two addresses in each subnet are reserved: the network address (all host bits zero) and the broadcast address (all host bits one). So usable hosts = 2(32 − prefix) − 2.
| Prefix | Subnet mask | Total addresses | Usable hosts |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
Special cases: /31 and /32
A /31 has only two addresses, and under RFC 3021 both can be used for point-to-point links, so there is no network or broadcast address. A /32 is a single host address, used for loopbacks and specific routes. The calculator reports 2 and 1 usable hosts for these.
Choosing a prefix
- Count the hosts you need now and add growth, then choose the smallest block that fits.
- Keep each network, such as office, servers and guest Wi-Fi, in its own subnet for security and tidier routing.
- Use /30 or /31 for links between two routers.
- Document the plan: addresses, purposes and gateways.
Private address ranges
| Range | Prefix | Use |
|---|---|---|
| 10.0.0.0 to 10.255.255.255 | 10.0.0.0/8 | Large private networks |
| 172.16.0.0 to 172.31.255.255 | 172.16.0.0/12 | Medium private networks |
| 192.168.0.0 to 192.168.255.255 | 192.168.0.0/16 | Home and small office |
These ranges are reserved for private use and are not routed on the public internet; routers use network address translation (NAT) to connect them.
Limits
This calculator is for IPv4. IPv6 uses 128-bit addresses with typical /64 subnets and does not have a broadcast address. It also does not design routing, variable-length subnetting plans or firewall rules.
Common mistakes
- Using the network or broadcast address for a device.
- Choosing a subnet too small for planned growth.
- Overlapping subnets in the same network.
- Mistaking a /24 mask 255.255.255.0 for the number of hosts. A /24 has 254 usable hosts.
Frequently asked questions
How do I find the number of subnets I can create?
Borrowing b bits from the host part creates 2b subnets. Splitting a /24 into /26 blocks gives 4 subnets.
What is CIDR?
Classless Inter-Domain Routing: the notation with a slash and prefix length, replacing the old class A, B and C system.
Can two devices have the same IP address?
Not on the same network. Duplicate addresses cause conflicts. The same private address can exist on different private networks.