A subnet is a smaller network carved out of a larger block of IP addresses, in which every address shares the same network prefix. The remaining bits of each address identify individual hosts. A prefix length such as /24 shows how many leading bits are shared. Networks use subnets to organize their addresses and to control how traffic is routed.
A /24 subnet contains 256 addresses, and an access rule written for a /24 matches all of them at once.
Subnet Masks and CIDR Notation
- Subnet mask: A 32-bit value whose leading 1 bits mark the network part of an IPv4 address. The mask 255.255.255.0 has 24 leading ones.
- CIDR notation: Writes the same mask as a prefix length after a slash, so 255.255.255.0 becomes /24.
- Block size: Each extra prefix bit halves the block. A /25 holds 128 addresses, a /23 holds 512, and a /32 is a single address.
- IPv6: Standard IPv6 unicast addresses reserve the last 64 bits for the interface ID, so the subnet prefix is 64 bits long (a /64).
Why Networks Use Subnets
Organizations split one network into subnets when a single local network is not practical. RFC 950, the original subnetting standard, lists reasons such as mixing different LAN technologies, limits on the number of hosts and cable length, congestion caused by a few busy hosts, and sites joined by point-to-point links. Because routing protocols carry the prefix length, routers can treat one subnet, or a group of neighboring subnets, as a single route.