What is a Subnet? IP Subnetting Explained
A subnet (subnetwork) is a logical subdivision of an IP network. Subnetting takes a block of IP addresses and divides it into smaller, more manageable pieces. It is fundamental to how networks are organized internally, how traffic is routed between networks, and how the global BGP routing table is structured.
The Address Structure
Every IP address has two conceptual parts: a network portion that identifies which network the address belongs to, and a host portion that identifies a specific device on that network. The prefix length — written in CIDR notation as the slash number — defines exactly where the boundary falls.
For the address 192.0.2.45/24:
- The first 24 bits (
192.0.2) are the network portion - The last 8 bits (
45) are the host portion - The subnet mask is
255.255.255.0(24 bits set to 1) - The network address is
192.0.2.0(host bits all zero) - The broadcast address is
192.0.2.255(host bits all one) - Usable host range:
192.0.2.1through192.0.2.254— 254 addresses
Subnet Masks and CIDR
Before 1993, the internet used a classful addressing scheme: Class A (/8), Class B (/16), and Class C (/24) were the only options. A company needing 500 addresses had to get a Class B block with 65,536 addresses — wasting over 65,000. CIDR (Classless Inter-Domain Routing), defined in RFC 4632, replaced this with arbitrary prefix lengths, allowing precise allocation.
The subnet mask is the binary complement of the host mask. A /24 subnet mask in binary is 24 ones followed by 8 zeros: 11111111.11111111.11111111.00000000, written as 255.255.255.0. A /26 is 11111111.11111111.11111111.11000000 = 255.255.255.192.
Common Subnet Sizes
| CIDR | Addresses | Usable hosts | Common use |
|---|---|---|---|
| /32 | 1 | 1 (host route) | Single host, loopback, BGP next-hop |
| /31 | 2 | 2 (RFC 3021) | Point-to-point links (no broadcast needed) |
| /30 | 4 | 2 | Classic point-to-point link |
| /28 | 16 | 14 | Small server cluster |
| /26 | 64 | 62 | Small office segment |
| /24 | 256 | 254 | Common LAN segment, smallest BGP-routed prefix |
| /22 | 1,024 | 1,022 | Mid-size ISP allocation |
| /20 | 4,096 | 4,094 | Large enterprise |
| /16 | 65,536 | 65,534 | Large ISP block |
| /8 | 16,777,216 | 16,777,214 | Legacy "Class A" (rare) |
Reserved and Special Subnets
Several IPv4 ranges are reserved for specific purposes and are never routed on the public internet:
10.0.0.0/8— RFC 1918 private, 16.7 million addresses, used inside large networks172.16.0.0/12— RFC 1918 private, spans 172.16.0.0 through 172.31.255.255192.168.0.0/16— RFC 1918 private, common home and office LANs100.64.0.0/10— RFC 6598 shared address space (Carrier-Grade NAT)127.0.0.0/8— Loopback, with 127.0.0.1 as the conventional loopback address169.254.0.0/16— Link-local / APIPA (auto-assigned when DHCP fails)192.0.2.0/24,198.51.100.0/24,203.0.113.0/24— RFC 5737 documentation addresses (used in examples)
Subnet Math
Given any CIDR block, the key calculations are:
- Number of addresses: 2(32 - prefix_length) for IPv4
- Network address: host bits of the given IP set to zero
- Broadcast address: host bits set to all ones
- Usable hosts: total addresses minus 2 (network + broadcast), except /31 and /32
Example: 10.0.5.128/25
- Addresses: 27 = 128 (10.0.5.128 through 10.0.5.255)
- Subnet mask: 255.255.255.128
- Network address: 10.0.5.128
- Broadcast: 10.0.5.255
- Usable hosts: 10.0.5.129 through 10.0.5.254 (126 hosts)
Subnetting and BGP
In the global BGP routing table, each announced prefix is a subnet that an autonomous system is advertising to the world. The routing table contains roughly one million IPv4 prefixes. Most are /24 or shorter (less specific), because prefixes more specific than /24 are typically filtered by other networks and will not propagate globally.
Networks use subnetting for traffic engineering. An organization with a /20 might announce the whole /20 for reachability, while also announcing individual /24 subnets via different upstream providers to control which provider carries traffic for which portion of their address space. BGP communities provide a finer-grained way to influence this without announcing additional specifics.
IPv6 Subnetting
For IPv6, the standard subnet size is /64. SLAAC (Stateless Address Autoconfiguration) requires a /64 because it uses the 64-bit host portion to embed the interface identifier. A typical home or office receives a /48 from their ISP, which they can divide into up to 65,536 /64 subnets — one per room, per device type, or per VLAN — without ever running out.
See Subnets in Practice
Look up different IPs within the same organization to see how address space is divided into announced subnets: