How subnetting works
An IPv4 address is 32 bits, written as four numbers from 0 to 255. The prefix length (the number after the slash) says how many of those bits name the network. The rest name a host on that network. In 192.168.1.10/24, the first 24 bits (192.168.1) are the network and the last 8 bits (.10) are the host.
The netmask is the same thing written as an address: 24 ones followed by 8 zeros is 255.255.255.0. To get the network address, the calculator keeps the bits where the mask is 1 and sets the rest to 0. Setting the host bits to 1 instead gives the broadcast address.
A worked example
Take 10.20.30.40/19. A /19 leaves 13 host bits, so the block has 213 = 8,192 addresses.
- The mask is 19 ones:
255.255.224.0. The third number, 224, is11100000in binary. - 30 in binary is
00011110. Keeping only the top 3 bits gives00000000, so the network is10.20.0.0. - Setting all 13 host bits gives the broadcast address,
10.20.31.255. - Usable hosts run from
10.20.0.1to10.20.31.254: 8,190 of them.
The number base converter is handy for checking the binary yourself.
Common subnet sizes
| Prefix | Netmask | Wildcard | Addresses | Usable hosts |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 |
/31 and /32 are special cases. A /31 is a point-to-point link where both addresses are usable (RFC 3021). A /32 is one address. Neither has a broadcast address.
Splitting a network
Each extra bit of prefix halves the block. A /24 splits into two /25s, four /26s or eight /27s. Pick a size in “Split into smaller subnets” to list them, with each one’s host range and broadcast address. Large splits list the first 256 and give the total.
If you need different sizes (say one subnet for 100 hosts and three for 20), start with the biggest. Give it the first block that fits, then carve the next size out of what’s left. Each subnet must start on a multiple of its own size: a /26 can start at .0, .64, .128 or .192, never .32.
Special address ranges
| Range | What it’s for |
|---|---|
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 | Private networks (RFC 1918) |
100.64.0.0/10 | Carrier-grade NAT (RFC 6598) |
127.0.0.0/8 | Loopback: this machine |
169.254.0.0/16 | Link-local, picked when DHCP fails |
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 | Documentation and examples |
224.0.0.0/4 | Multicast |
IPv6
IPv6 addresses are 128 bits, written as eight groups of four hex digits. Runs of zero groups can be shortened to :: once per address, so 2001:0db8:0000:0000:0000:0000:0000:0001 is 2001:db8::1. The calculator shows both forms, using the short form recommended by RFC 5952.
There’s no broadcast address in IPv6 and no need to subtract two: every address in the block can be used. Address counts are huge, so they’re shown exactly and as a power of 10.
Common mistakes
- Using the network or broadcast address for a device. In a /24, .0 and .255 are taken. Type an address in “Is this address in the block?” to check.
- Overlapping subnets. 10.0.0.0/23 already includes 10.0.1.0/24. Split from one parent block to avoid it.
- Mixing up netmask and wildcard. Access lists want the wildcard; interface settings want the netmask. The calculator spots a wildcard typed where a netmask should be.
- Leading zeros. Some software reads
010as octal (8), so192.168.010.1may not mean what you think. Write10.
Setting up a server? The chmod calculator explains file permissions, and the HTTP status codes list explains what your web server sends back.