IPv4 subnet sizes are defined by a prefix length (e.g., /24) that tells you how many addresses are in the block and how they split into network and host parts. This guide explains how to read those prefixes, calculate the number of usable IPs, choose the right size for your needs, and avoid common mistakes.
Formula
The number of addresses in an IPv4 block is 2^(32 – prefix). For a prefix /p, the block contains 2^(32-p) total addresses. The first address is the network identifier, the last is the broadcast address, and the ones in between are usable by hosts. So usable hosts = total – 2.
Variables: p = prefix length (e.g., 24 for a /24), total = 2^(32-p), usable = total – 2.
Worked Example
For a /24 subnet (the most common home/office size): total = 2^(32-24) = 2^8 = 256 addresses. Subtract the network address (e.g., 192.168.1.0) and the broadcast address (192.168.1.255), leaving 254 usable host addresses. The calculator above with defaults 256 and /24 gives 254 usable – matching exactly.
Why Subnet Sizes Matter
Every device on a network – computer, phone, printer, IoT sensor – needs a unique IP address. The subnet size determines how many devices can be connected directly without routing. Too small a block and you run out of addresses; too large and you waste address space (and can create larger broadcast domains that slow performance). Understanding prefixes is essential for planning a new network, troubleshooting DHCP exhaustion, or setting up VLANs.
IPv4 addresses are 32 bits long, written as four octets (e.g., 192.168.1.0). The prefix length indicates how many of those bits are fixed as the network part. The remaining bits are host bits. A /24 means 24 network bits and 8 host bits. Each additional host bit doubles the number of addresses.
Common Prefixes and Their Sizes
- /30 – 4 total, 2 usable. Typically used for point-to-point links between routers.
- /29 – 8 total, 6 usable. Small networks, often for a handful of servers or a small branch office.
- /28 – 16 total, 14 usable. Small LANs, e.g., a home office with a few devices.
- /24 – 256 total, 254 usable. The classic single-subnet size for homes and small businesses.
- /16 – 65,536 total, 65,534 usable. Large organizations or private ranges like 10.0.0.0/16.
- /8 – 16,777,216 total, 16,777,214 usable. Huge blocks, mostly used by ISPs or large cloud providers.
Notice the pattern: each decrease in prefix by 1 doubles the number of addresses. A /23 is 512 addresses, a /22 is 1,024, and so on. This exponential relationship is the key to quickly estimating sizes.
How to Choose the Right Subnet Size
Start by counting the devices that will be on the subnet today, then add room for growth – often 20-50% more. Remember that the network and broadcast addresses are not usable, so you always need at least 2 more addresses than devices. For example, if you have 200 devices, a /24 (254 usable) is sufficient; if you have 300, you need a /23 (510 usable).
Consider future needs: will you add cameras, sensors, or guest Wi-Fi? Each of those might require its own subnet. Also think about whether you need to segment traffic for security or performance. A common practice is to use /24 for general user networks, /25 (128 addresses) for smaller groups, and /30 for router links.
Common Problems and Misconceptions
One frequent mistake is forgetting to subtract 2 for the network and broadcast addresses. Another is confusing the prefix length with the number of usable hosts – a /24 is not 24 usable addresses; it’s 254. People also mix up private vs. public ranges: private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) are not routable on the internet, so they can be reused freely inside your organization. Public IPs are scarce and must be requested from an ISP or RIR.
Another issue is overlapping subnets. If you assign the same subnet (e.g., 192.168.1.0/24) to two different VLANs without proper routing, devices may not communicate correctly. Always plan your IP scheme centrally to avoid overlaps.
Comparing IPv4 and IPv6 Subnet Sizes
IPv6 uses a completely different scale. A typical IPv6 subnet is a /64, which contains 2^64 addresses – an astronomically large number. The reason is that IPv6 was designed to eliminate the need for NAT and to simplify address assignment via SLAAC. While IPv4 subnetting is about conserving addresses, IPv6 subnetting is about structuring the address hierarchy. For most users, the practical difference is that you never worry about running out of addresses in a /64.
When migrating from IPv4 to IPv6, you often keep the same subnet topology but replace the IPv4 ranges with IPv6 /64s. The prefix length in IPv6 is usually fixed at /64 for LANs, with /48 or /56 assigned to sites.
Safety and Efficiency Tips
Always document your subnet plan – which VLAN uses which block. Use a consistent scheme, such as assigning /24s in order (192.168.1.0/24, 192.168.2.0/24, etc.) to make troubleshooting easier. Avoid using the broadcast address or network address for hosts; they are reserved by the protocol. When setting up DHCP, make sure the pool excludes the addresses you use for static devices (like printers or servers) to prevent conflicts.
For security, consider using smaller subnets for sensitive devices (e.g., IP cameras on a /28) to limit exposure. But remember that subnetting alone is not a firewall; you still need proper ACLs and segmentation.
Frequently Asked Questions
What does /24 mean in IP addressing? A /24 means the first 24 bits of the IP address are the network part, leaving 8 bits for hosts. That gives 256 total addresses, but only 254 are usable because the first is the network address and the last is the broadcast.
How many usable IPs are in a /28? A /28 has 16 total addresses (2^(32-28) = 16). Subtract 2 for network and broadcast, leaving 14 usable host addresses.
Why can’t I use the first and last IP in a subnet? The first address is the network identifier – it represents the whole subnet, not a specific device. The last address is the broadcast address – a special address that sends a packet to all hosts on that subnet. Using them for a device would cause conflicts.
What is the difference between a /24 and a /25? A /24 has 256 addresses (254 usable), while a /25 has 128 addresses (126 usable). A /25 is half the size of a /24. You can think of a /24 as two /25s.
How do I calculate the subnet mask from a prefix? The subnet mask is a 32-bit number where the first p bits are 1 and the rest are 0. For /24, the mask is 255.255.255.0. For /16, it’s 255.255.0.0. You can also use the formula: mask = 2^32 – 2^(32-p).
Can I have a subnet larger than /8? Technically yes, but /8 is the largest common prefix in IPv4 (16.7 million addresses). Prefixes smaller than /8 (like /7) exist but are rarely used because they represent huge blocks that are difficult to manage and route.
Related
Formula used
in t | Total addresses in block | addresses | 256 | 1 | 4294967296 in p | Prefix length | bits | 24 | 0 | 32 out usable | Usable host addresses | addresses | t - 2 | 0 out network | Network address (first usable) | - | 0 | 0 out broadcast | Broadcast address (last usable) | - | t - 1 | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Philips DST7060/20 7000 Series Iron: Specs & Fit
- Coal Fueled Jet Aircraft: Could It Work?675 L
- Remote Desktop on Raspberry Pi: How to Enable It
- Word Select Last Line in Paragraph?
- Google Assistant IFTTT Recipes: 7 Useful Automations
- OLED TVs in Dark Rooms: Why They Look Better and When They Don’t