CIDR & Subnets Explained
Understand CIDR notation, subnet masks, network and broadcast addresses, and how to calculate how many hosts a subnet holds.
CIDR (Classless Inter-Domain Routing) notation describes a block of IP addresses as an address plus a prefix length, like 192.168.1.0/24. The number after the slash says how many leading bits are the network portion.
What the /prefix means
An IPv4 address has 32 bits. A /24 means the first 24 bits identify the network and the remaining 8 bits identify hosts โ that's 2โธ = 256 addresses. The subnet mask for /24 is 255.255.255.0.
Network, broadcast, and usable hosts
- Network address โ the first address in the block (all host bits 0).
- Broadcast address โ the last address (all host bits 1).
- Usable hosts โ everything in between. For
/24, that's 256 โ 2 = 254 usable addresses.
Smaller prefixes, bigger networks
A smaller prefix number means a bigger network: /16 holds 65,536 addresses, while /30 holds just 4 (2 usable) โ handy for point-to-point links.