Subnetting Explained: CIDR Notation and Subnet Masks
Understand IPv4 subnets: what /24 and 255.255.255.0 mean, how to find the network, broadcast and host range, and how to split a network into smaller subnets.
IPv4 addresses are 32-bit numbers
An IPv4 address such as 192.168.1.130 is written as four numbers from 0 to 255, but a computer sees one 32-bit binary number. Each of the four parts, called an octet, is eight bits:
- 192 = 11000000
- 168 = 10101000
- 1 = 00000001
- 130 = 10000010
Subnetting is easier once you remember that every address splits into two parts: the network bits at the start, which are the same for every device on the subnet, and the host bits at the end, which number the individual devices. The number base converter helps when you want to see an octet in binary.
What the prefix and the mask mean
CIDR notation writes the split as a slash and a number: 192.168.1.130/26 means the first 26 bits are the network part and the remaining 6 bits are for hosts. A subnet mask says the same thing as an address-shaped number with 1s for network bits and 0s for host bits.
A /24 mask is 24 ones followed by 8 zeros, which is 255.255.255.0. A /26 mask is 26 ones, so the last octet is 11000000, which is 192, giving 255.255.255.192. Whether a device shows the prefix or the mask, it is the same information.
Network, broadcast and usable hosts
With h host bits, a subnet holds 2^h addresses. The first one, with all host bits set to 0, is the network address. The last, with all host bits set to 1, is the broadcast address. Everything in between can be given to devices, so a subnet has 2^h − 2 usable hosts.
For 192.168.1.130/26 there are 6 host bits, so each subnet holds 64 addresses. The last octet, 130, falls in the block that starts at 128, so:
- Network address: 192.168.1.128
- First usable host: 192.168.1.129
- Last usable host: 192.168.1.190
- Broadcast address: 192.168.1.191
- Usable hosts: 62
The subnet calculator shows all of this, plus the masks in decimal and binary, for any address.
Common prefixes at a glance
These are the prefixes you meet most often in small and medium networks:
- /30: mask 255.255.255.252, 4 addresses, 2 usable hosts
- /29: 255.255.255.248, 8 addresses, 6 usable
- /28: 255.255.255.240, 16 addresses, 14 usable
- /27: 255.255.255.224, 32 addresses, 30 usable
- /26: 255.255.255.192, 64 addresses, 62 usable
- /25: 255.255.255.128, 128 addresses, 126 usable
- /24: 255.255.255.0, 256 addresses, 254 usable
- /16: 255.255.0.0, 65,536 addresses, 65,534 usable
Two special cases: a /31 has no network or broadcast address and both addresses can be used on a point-to-point link (RFC 3021), and a /32 is a single host.
Splitting a network into subnets
Each bit you move from the host part to the network part doubles the number of subnets and halves their size. Splitting 192.168.1.0/24 into four equal subnets takes two extra bits, giving four /26 subnets that start at 192.168.1.0, 192.168.1.64, 192.168.1.128 and 192.168.1.192, each with 62 usable hosts.
To choose a prefix, start from the number of devices you need and leave room to grow. A floor with 50 devices needs at least 52 addresses including the network and broadcast, so a /26 with 62 usable hosts fits, while a /27 with 30 would be too small.
Private ranges and special addresses
RFC 1918 reserves three ranges for private networks that are not routed on the internet: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. Home routers, offices and cloud networks use these behind NAT.
Other ranges have special jobs: 127.0.0.0/8 is loopback, 169.254.0.0/16 is link-local (an address a device gives itself when no DHCP server answers), and 100.64.0.0/10 is shared space for carrier-grade NAT (RFC 6598). Router access lists often use a wildcard mask, the inverse of the subnet mask: 0.0.0.63 for a /26. When a host name will not resolve to the address you expect, the DNS lookup shows the records.
Common questions
Is /24 the same as 255.255.255.0?
Yes. Both say that the first 24 bits are the network part. Some systems ask for the prefix and others for the mask.
How many /24 networks fit in a /16?
- Moving from /16 to /24 adds 8 network bits, and 2 to the power of 8 is 256.
Why can’t I give .0 or .255 to a device in a /24?
In a /24, .0 is the network address and .255 is the broadcast address. Only .1 to .254 are usable hosts.
Last updated: