What is a subnet?
A subnet is a block of consecutive IP addresses that belong together, such as the devices on one home or office network. Its size is set by the prefix length: in 192.168.1.0/24, the first 24 of the address's 32 bits identify the network and the remaining 8 bits number the devices on it, giving 256 addresses.
The same split can be written as a netmask: /24 is 255.255.255.0, with one bits for the network part and zero bits for the host part. The wildcard mask is the opposite (0.0.0.255) and is used in router access lists.
Usable hosts
In IPv4, the first address of a subnet is the network address and the last is the broadcast address, so neither can be given to a device: a /24 has 256 addresses but 254 usable hosts. Two exceptions: a /31 has two usable addresses for point-to-point links (RFC 3021), and a /32 is a single host. IPv6 has no broadcast address, so every address in the range is usable.
Private address ranges
These IPv4 ranges are reserved for private networks (RFC 1918) and are never routed on the internet. Your router gives devices addresses from one of them and translates to your public IP address (NAT).
| Range | CIDR | Addresses |
|---|---|---|
| 10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | 16,777,216 |
| 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | 1,048,576 |
| 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | 65,536 |
Mobile and some home internet providers also use 100.64.0.0/10 for carrier-grade NAT, which is why your router's outside address can differ from the public address websites see.
IPv4 subnet reference
| Prefix | Netmask | Addresses | Usable hosts |
|---|---|---|---|
/8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
/9 | 255.128.0.0 | 8,388,608 | 8,388,606 |
/10 | 255.192.0.0 | 4,194,304 | 4,194,302 |
/11 | 255.224.0.0 | 2,097,152 | 2,097,150 |
/12 | 255.240.0.0 | 1,048,576 | 1,048,574 |
/13 | 255.248.0.0 | 524,288 | 524,286 |
/14 | 255.252.0.0 | 262,144 | 262,142 |
/15 | 255.254.0.0 | 131,072 | 131,070 |
/16 | 255.255.0.0 | 65,536 | 65,534 |
/17 | 255.255.128.0 | 32,768 | 32,766 |
/18 | 255.255.192.0 | 16,384 | 16,382 |
/19 | 255.255.224.0 | 8,192 | 8,190 |
/20 | 255.255.240.0 | 4,096 | 4,094 |
/21 | 255.255.248.0 | 2,048 | 2,046 |
/22 | 255.255.252.0 | 1,024 | 1,022 |
/23 | 255.255.254.0 | 512 | 510 |
/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 |
/31 | 255.255.255.254 | 2 | 2 |
/32 | 255.255.255.255 | 1 | 1 |
IPv6 subnets
IPv6 addresses are 128 bits long, so subnets are much larger. A single network segment is normally a /64, leaving 64 bits for devices. Internet providers typically give homes a /56 or /48, which holds 256 or 65,536 such /64 networks.