What Is a Subnet? Complete Subnet Mask & CIDR Architecture Guide
IP addressing is the foundational pillar of modern networking and the Internet. For network engineers, systems administrators, and DevOps professionals, subnetting is the essential skill for building efficient routing domains, enforcing granular firewall security zones, and optimizing scarce IPv4 address space. This guide explains what a subnet is, how subnet masks work at the binary level, and how CIDR prefix notation ties everything together.
1. What Is a Subnet and Why Do We Need It?
"Subnet" is shorthand for sub-network. Subnetting is the practice of partitioning a single large broadcast domain into smaller, independent network segments, each with its own network address, host address range, and broadcast address.
Running thousands of endpoints on one flat network creates severe problems:
- Broadcast storms: ARP requests are flooded to every switch port in the VLAN. On a flat network of 5,000 devices, every connected NIC processes each broadcast, driving up CPU load and consuming bandwidth.
- Missing security isolation: When finance, HR, server clusters, and guest Wi-Fi share a single subnet, any compromised host can reach everything. Separate subnets let stateful firewalls and ACLs inspect and control all inter-subnet traffic.
- Inefficient IP usage: Reserving a Class B-sized block of 65,534 usable hosts for a small branch office strands tens of thousands of addresses that other segments could use.
Every subnet boundary is simultaneously a traffic boundary, a security boundary, and an addressing boundary — which is why subnetting is the first design decision in nearly every network project.
2. How a Subnet Mask Works: The Binary Mechanics
Every IPv4 address comprises 32 bits organized into four 8-bit octets. A standalone address such as 192.168.1.50 does not reveal where the network identifier ends and the host identifier begins. The subnet mask provides this delineation:
- Consecutive 1 bits from the left specify the network bits.
- Consecutive 0 bits to the right specify the host bits.
When a host or router needs to determine which network an address belongs to, it performs a bitwise AND between the address and the subnet mask. The result is the network address:
IP address : 11000000.10101000.00000001.00110010 (192.168.1.50) Subnet mask : 11111111.11111111.11111111.00000000 (255.255.255.0) AND result : 11000000.10101000.00000001.00000000 (192.168.1.0)
If the sender and the destination reduce to the same network address, they communicate directly at Layer 2. If the results differ, the packet is handed to the default gateway for routing.
Two rules govern every subnet:
- The mask must be contiguous: all the 1s first, then all the 0s. A mask such as
255.0.255.0is invalid. - With h host bits, a subnet contains 2^h total addresses and 2^h − 2 usable hosts, because the all-zeros host address is reserved as the network ID and the all-ones host address as the broadcast.
3. CIDR: From Classful Networks to Slash Notation
Before CIDR, IPv4 used a rigid classful architecture with only three default sizes:
- Class A: first octet 1–126, default mask 255.0.0.0 (/8), 16,777,214 usable hosts
- Class B: first octet 128–191, default mask 255.255.0.0 (/16), 65,534 usable hosts
- Class C: first octet 192–223, default mask 255.255.255.0 (/24), 254 usable hosts
The problem was granularity. A company with 300 computers did not fit into a Class C, so it was forced onto a Class B — leaving more than 65,000 addresses idle. In 1993, the IETF standardized CIDR (Classless Inter-Domain Routing), which discards fixed classes entirely: the prefix length simply counts the network bits, so the network/host boundary can fall on any bit from /0 to /32. A /20 means 20 network bits, mask 255.255.240.0, and 4,094 usable hosts.
Dotted-decimal masks and CIDR prefixes are two notations for the same boundary: 255.255.255.0 is /24, and /26 is 255.255.255.192. Slash notation is shorter, unambiguous, and is what routing tables, firewall rules, and cloud consoles expect.
4. The Complete Subnet Mask and CIDR Reference Table
The table below lists every valid IPv4 prefix from /8 to /32, with the dotted-decimal mask, the wildcard mask (its inverse, used in ACLs), the total number of addresses, and the usable host count:
| CIDR | Subnet Mask | Wildcard Mask | Total Addresses | Usable Hosts |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 0.127.255.255 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 0.63.255.255 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 0.31.255.255 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 0.7.255.255 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 0.3.255.255 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 0.1.255.255 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 0.0.127.255 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 0.0.63.255 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 0.0.31.255 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 |
Two special cases sit at the bottom of the table. A /31 contains exactly two addresses, and per RFC 3021 both are usable on point-to-point links, because no network or broadcast address is needed. A /32 identifies a single host and is commonly used for loopback interfaces and host-specific routes.
5. Worked Example: Splitting 192.168.10.0/24 into /26 Subnets
Scenario: an office has four floors, and each floor must accommodate up to 60 devices. You have been given 192.168.10.0/24.
- Find the required host bits. You need 2^h − 2 ≥ 60; with h = 6 you get 62 usable hosts, so a /26 (mask 255.255.255.192) fits each floor.
- Count the new subnets. You borrow s = 26 − 24 = 2 bits from the host portion, producing 2^2 = 4 subnets — exactly one per floor.
- Compute the block size. Subtract the last mask octet from 256: 256 − 192 = 64. Boundaries fall on multiples of 64 in the fourth octet: 0, 64, 128, and 192.
- Write out each subnet. The first address is the network ID, the last is the broadcast, and everything in between is usable:
| Segment | Network Address | First Usable | Last Usable | Broadcast |
|---|---|---|---|---|
| Floor 1 | 192.168.10.0/26 | 192.168.10.1 | 192.168.10.62 | 192.168.10.63 |
| Floor 2 | 192.168.10.64/26 | 192.168.10.65 | 192.168.10.126 | 192.168.10.127 |
| Floor 3 | 192.168.10.128/26 | 192.168.10.129 | 192.168.10.190 | 192.168.10.191 |
| Floor 4 | 192.168.10.192/26 | 192.168.10.193 | 192.168.10.254 | 192.168.10.255 |
For a deeper drill on this method, see our step-by-step subnetting tutorial, and use the /26 subnet reference page to verify results instantly.
6. VLSM: Right-Sizing Every Subnet
Fixed-length subnetting — giving every segment the same mask — is simple but wasteful when requirements differ. VLSM (Variable Length Subnet Masking) lets you mix prefix lengths inside one block. The method: sort requirements from largest to smallest, allocate the biggest first, and keep every subnet aligned to its block size.
Example with 192.168.20.0/24:
- Sales, 100 hosts: needs 2^7 − 2 = 126 → /25 →
192.168.20.0/25, usable .1–.126, broadcast .127 - Engineering, 50 hosts: needs 2^6 − 2 = 62 → /26 →
192.168.20.128/26, usable .129–.190, broadcast .191 - Server farm, 20 hosts: needs 2^5 − 2 = 30 → /27 →
192.168.20.192/27, usable .193–.222, broadcast .223 - Router-to-router link: /30 →
192.168.20.224/30, usable .225–.226, broadcast .227
The space from .228 upward remains free for future growth. Our VLSM calculator guide walks through this process in more detail.
7. Real-World Subnet Design Patterns
Offices and VLANs
The standard enterprise pattern is one subnet per VLAN: user VLANs on /24s for comfortable headroom, printer and management VLANs on smaller blocks such as /27 or /28. Reserve the first usable address of each subnet for the default gateway so documentation stays predictable across segments.
Point-to-Point Links
Router-to-router and site-to-site links need exactly two addresses. A /30 provides 2 usable hosts and is the traditional choice; a /31 (per RFC 3021) serves the same two endpoints with half the address consumption and is supported by modern routers.
Cloud VPCs
Cloud platforms are built entirely on CIDR. A typical design allocates a large private block — for example a /16 — to the virtual network, then carves it into /24 or smaller subnets per availability zone. Because subnets cannot overlap, plan ranges up front; the RFC 1918 private address ranges guide explains which blocks are safe to use.
IPv6 makes different trade-offs — its subnets are conventionally /64, and there is no broadcast address — so IPv4 habits do not transfer directly. Read IPv4 vs IPv6 subnetting differences before designing dual-stack networks.
8. Common Mistakes to Avoid
- Counting the network and broadcast addresses as usable. Capacity is always 2^h − 2: a /28 supports 14 hosts, not 16.
- Assuming .0 and .255 are always the boundaries. That is only true for /24. In
192.168.1.50/26, the network address is 192.168.1.0 and the broadcast is 192.168.1.63 — the subnet ends long before .255. - Using non-contiguous masks. The 1s must be consecutive;
255.255.15.0is not a valid mask. - Creating overlapping subnets. Two interfaces advertising the same or nested ranges cause ambiguous routing and unstable route selection.
- Forgetting infrastructure addresses. The gateway, DHCP server, and static reservations all consume usable addresses — size each subnet for devices plus overhead, with room to grow.
Subnetting fluency comes from repetition: work through our CCNA subnetting practice questions until the block sizes are second nature.
Frequently Asked Questions (FAQ)
What is the primary purpose of subnetting? →
Subnetting divides a large broadcast domain into smaller, logically isolated subnets. This reduces broadcast traffic overhead, reinforces firewall boundaries, and eliminates IP address wastage.
What is the relationship between a subnet mask and CIDR? →
A subnet mask expresses the network versus host bit boundary in dotted decimal (such as 255.255.255.0), while CIDR expresses the exact count of consecutive network bits in slash notation (such as /24). Both notations describe the same boundary.
Why can the first and last IP of a subnet not be assigned to hosts? →
In standard IPv4 subnets, the all-zeros host address represents the network ID itself, and the all-ones host address is reserved for broadcast packets. That is why the formula for usable hosts is always 2^h - 2.
What are /31 and /32 subnets used for? →
A /31 contains exactly two addresses, and per RFC 3021 both can be used on point-to-point links because no network or broadcast address is required. A /32 designates a single host and is commonly used for loopback interfaces and host-specific routes.
How do I choose the right subnet mask for a given number of hosts? →
Find the smallest number of host bits h for which 2^h - 2 covers your requirement, remembering to include the gateway and any reserved addresses. For example, 50 hosts need h = 6, which is a /26 with 62 usable addresses.
How many subnets do I get when I subnet a network? →
The number of subnets equals 2 raised to the number of borrowed bits. Extending a /24 to a /26 borrows 2 bits, so it yields 4 subnets, each with 62 usable hosts.