Subnet Calculator
Free subnet calculator - get network address, broadcast address, usable host range, wildcard mask, and IP class from any CIDR or subnet mask.
Enter an IP address with a CIDR prefix (like 192.168.1.0/24) or a dotted-decimal subnet mask, and this calculator instantly shows the network address, broadcast address, first and last usable hosts, number of usable hosts, wildcard mask, IP class, and binary representation. All calculations run in your browser with no data transmitted.
About Subnet Calculator
What Is Subnetting and Why Does It Matter?
Subnetting divides a large IP network into smaller subnetworks. An IPv4 address is 32 bits long, giving a total of 4,294,967,296 possible addresses. The subnet mask determines how many bits identify the network (the network portion) and how many identify individual hosts (the host portion). All devices on the same subnet share the same network portion.
Subnetting exists because flat networks are impractical. A single broadcast domain with thousands of hosts generates excessive broadcast traffic that degrades performance. By splitting a large network into subnets, broadcasts are contained within each segment, security policies can be applied per-subnet, and routing becomes more efficient.
The Internet Engineering Task Force (IETF) introduced Classless Inter-Domain Routing (CIDR) in 1993 through RFC 1519, later updated by RFC 4632 in 2006. CIDR replaced the rigid classful system where organizations received either a Class A (16.7 million addresses), Class B (65,534 addresses), or Class C (254 addresses) block - with nothing in between. A company needing 300 addresses would get a Class B with 65,534, wasting 99.5% of the allocation. CIDR allows variable-length subnet masks (VLSM), so the same company could receive a /23 with exactly 510 usable addresses.
How Subnet Calculations Work
Every subnet calculation starts with an IP address and a prefix length (CIDR notation) or subnet mask. The prefix length tells the calculator how many leading bits are the network portion. Here is the step-by-step process:
Worked example for 10.20.30.40/21:
1. Convert the IP to binary: 10.20.30.40 = 00001010.00010100.00011110.00101000
2. The /21 prefix means the first 21 bits are the network portion. The subnet mask is 21 ones followed by 11 zeroes: 11111111.11111111.11111000.00000000 = 255.255.248.0
3. AND the IP with the mask to get the network address: 00001010.00010100.00011000.00000000 = 10.20.24.0
4. Invert the mask to get the wildcard: 00000000.00000000.00000111.11111111 = 0.0.7.255
5. OR the network address with the wildcard to get the broadcast: 00001010.00010100.00011111.11111111 = 10.20.31.255
6. First usable host = network + 1 = 10.20.24.1. Last usable host = broadcast - 1 = 10.20.31.254
7. Total addresses = 2^(32 - 21) = 2,048. Usable hosts = 2,048 - 2 = 2,046 (subtract network and broadcast addresses).
CIDR Notation Reference
| CIDR | Subnet Mask | Wildcard Mask | Total Addresses | Usable Hosts | Typical Use |
|---|---|---|---|---|---|
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 | Host route (single IP) |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 (point-to-point) | Router-to-router links (RFC 3021) |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 | Point-to-point links (traditional) |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 | Small office or DMZ |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 | Small team or VLAN |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 | Small department |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 | Medium department |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 | Half of a Class C |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 | Standard LAN (most common) |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 | Two /24s combined |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 | Large office floor |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 | Large enterprise or campus |
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 | Class A allocation |
How Are Usable Hosts Calculated?
The formula is: usable hosts = 2^(32 - prefix) - 2. The two subtracted addresses are the network address and the broadcast address, which cannot be assigned to devices.
| Address | What It Is | Example (/24 on 192.168.1.0) |
|---|---|---|
| Network address | All host bits set to 0 - identifies the subnet itself | 192.168.1.0 |
| Broadcast address | All host bits set to 1 - sends to all hosts in subnet | 192.168.1.255 |
| First usable host | Network address + 1 | 192.168.1.1 |
| Last usable host | Broadcast address - 1 | 192.168.1.254 |
Exception: /31 subnets (RFC 3021) are a special case for point-to-point links where both addresses are usable because no broadcast is needed. /32 is a single host address used for loopback and host routes.
Second worked example for 172.16.50.0/28: Total addresses = 2^(32-28) = 16. Usable hosts = 16 - 2 = 14. Network address = 172.16.50.0, broadcast = 172.16.50.15, first host = 172.16.50.1, last host = 172.16.50.14. The subnet mask is 255.255.255.240 and the wildcard mask is 0.0.0.15.
What Is a Wildcard Mask?
A wildcard mask is the bitwise inverse of the subnet mask. Where the subnet mask has 1-bits, the wildcard has 0-bits, and vice versa. To convert, subtract each octet of the subnet mask from 255. For 255.255.255.192: 255-255=0, 255-255=0, 255-255=0, 255-192=63, giving 0.0.0.63.
| Subnet Mask | Wildcard Mask | Used In |
|---|---|---|
| 255.255.255.0 | 0.0.0.255 | Cisco ACLs, OSPF area commands |
| 255.255.255.252 | 0.0.0.3 | Matching a /30 link in ACL |
| 255.255.0.0 | 0.0.255.255 | Matching an entire /16 block |
Wildcard masks are primarily used in Cisco IOS commands for access control lists (ACLs) and OSPF configuration. A 0-bit means "must match" and a 1-bit means "don't care". Juniper and most modern platforms use standard subnet masks instead, but wildcard masks remain a core part of the CCNA and CCNP curriculum.
IP Address Classes
| Class | First Octet Range | Default Mask | Networks | Hosts per Network |
|---|---|---|---|---|
| A | 1-126 | /8 (255.0.0.0) | 126 | 16,777,214 |
| B | 128-191 | /16 (255.255.0.0) | 16,384 | 65,534 |
| C | 192-223 | /24 (255.255.255.0) | 2,097,152 | 254 |
| D | 224-239 | N/A | Multicast | N/A |
| E | 240-255 | N/A | Reserved | N/A |
Classful networking was replaced by CIDR in 1993 because it wasted address space. The three problems driving CIDR adoption, as documented in RFC 4632, were exhaustion of the Class B space, unsustainable routing table growth, and eventual exhaustion of the entire 32-bit IPv4 space. IANA allocated the last five /8 blocks on 3 February 2011, and as of early 2026, 45% of the total 3.687 billion allocated IPv4 addresses are held in ARIN's registry, 24% in APNIC, and 23% in RIPE NCC.
Private IP Address Ranges (RFC 1918)
| Range | CIDR | Class | Total Addresses | Common Use |
|---|---|---|---|---|
| 10.0.0.0 - 10.255.255.255 | 10.0.0.0/8 | A | 16,777,216 | Large enterprise, cloud VPCs (AWS, Azure, GCP) |
| 172.16.0.0 - 172.31.255.255 | 172.16.0.0/12 | B | 1,048,576 | Medium enterprise, Docker default (172.17.0.0/16) |
| 192.168.0.0 - 192.168.255.255 | 192.168.0.0/16 | C | 65,536 | Home networks, small office LANs |
These ranges are defined in RFC 1918 (February 1996) and are not routable on the public internet. NAT (Network Address Translation) allows devices on private networks to share a single public IP address. Most home routers use 192.168.0.0/24 or 192.168.1.0/24 by default, while enterprise networks typically use the 10.0.0.0/8 space because it provides over 16 million addresses for internal subnetting.
Supernetting and Route Aggregation
Supernetting is the opposite of subnetting - it combines multiple smaller networks into a single larger one for routing purposes. If an organization owns 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, and 192.168.3.0/24, these four /24 networks can be summarized as a single 192.168.0.0/22 route. This reduces the number of entries in routing tables from four to one.
Route aggregation is critical for internet-scale routing. The global IPv4 routing table contained over 1 million prefixes as of 2025. Without aggregation, routers would need far more memory and processing power. Internet service providers use supernetting extensively to advertise compact route summaries to their upstream peers.
For supernetting to work, the component networks must be contiguous and aligned on a power-of-two boundary. You cannot aggregate 192.168.1.0/24 and 192.168.3.0/24 into a single prefix because 192.168.2.0/24 sits between them.
Subnet Design for Real Networks
Planning a subnet scheme for a real network involves balancing address efficiency against growth capacity. A useful approach is to start by counting the hosts in each segment, then choose the smallest subnet that fits with room to grow.
| Segment | Hosts Needed | Recommended CIDR | Usable Hosts | Growth Room |
|---|---|---|---|---|
| Server VLAN | 20 | /27 | 30 | 10 spare |
| Staff VLAN | 100 | /25 | 126 | 26 spare |
| Guest Wi-Fi | 50 | /26 | 62 | 12 spare |
| IoT devices | 30 | /26 | 62 | 32 spare |
| Management | 5 | /29 | 6 | 1 spare |
| Point-to-point link | 2 | /30 | 2 | None |
A common practice is to allocate the 10.0.0.0/8 space for internal use, assigning each site a /16 (10.1.0.0/16, 10.2.0.0/16) and then subnetting within each site. This provides 256 sites with 65,534 addresses each - enough for most organizations. Cloud providers follow similar patterns: AWS VPCs default to a /16 within the 10.0.0.0/8 or 172.16.0.0/12 range.
Special Address Ranges
Beyond RFC 1918 private ranges, several other address blocks have special purposes defined by IANA:
| Range | CIDR | Purpose | Defined In |
|---|---|---|---|
| 127.0.0.0 - 127.255.255.255 | 127.0.0.0/8 | Loopback (localhost) | RFC 1122 |
| 169.254.0.0 - 169.254.255.255 | 169.254.0.0/16 | Link-local (APIPA) | RFC 3927 |
| 100.64.0.0 - 100.127.255.255 | 100.64.0.0/10 | Carrier-grade NAT (CGNAT) | RFC 6598 |
| 192.0.2.0 - 192.0.2.255 | 192.0.2.0/24 | Documentation (TEST-NET-1) | RFC 5737 |
| 198.51.100.0 - 198.51.100.255 | 198.51.100.0/24 | Documentation (TEST-NET-2) | RFC 5737 |
| 203.0.113.0 - 203.0.113.255 | 203.0.113.0/24 | Documentation (TEST-NET-3) | RFC 5737 |
The 169.254.0.0/16 link-local range is used by devices that cannot obtain an address from DHCP. Windows assigns an address in this range automatically (called APIPA - Automatic Private IP Addressing) when DHCP fails. The 100.64.0.0/10 range was allocated in 2012 for carrier-grade NAT, where ISPs place customers behind a second layer of NAT to conserve public IPv4 addresses.
Common Subnetting Mistakes
Forgetting to subtract 2 from the total host count is the most common error. A /24 has 256 total addresses, but only 254 are usable because the network address (.0) and broadcast address (.255) are reserved. Another frequent mistake is confusing the subnet mask with the wildcard mask - the wildcard is the inverse, not the same value. Using 0.0.0.255 where 255.255.255.0 is expected (or vice versa) breaks routing and ACL configurations.
Overlapping subnets cause difficult-to-diagnose routing problems. If one VLAN uses 10.1.0.0/23 (10.1.0.0 - 10.1.1.255) and another uses 10.1.1.0/24 (10.1.1.0 - 10.1.1.255), the second range falls entirely within the first, creating conflicts. Always map out your subnets on paper or in a planning tool before deploying.
Another common mistake is not accounting for network infrastructure. Routers, switches, access points, and printers all need addresses within each subnet. A department with 25 workstations and 5 infrastructure devices needs at least 30 addresses - a /27 with 30 usable hosts is technically sufficient, but a /26 with 62 usable hosts gives room to add devices without re-subnetting.
For converting individual octets between binary and decimal, the binary to decimal converter handles that. For working with different number bases used in network configuration, the number base converter is useful. And for hex conversions relevant to IPv6, see the hex to decimal converter.
Sources
Frequently Asked Questions
What is CIDR notation and how do I use it?
CIDR (Classless Inter-Domain Routing) notation combines an IP address with a prefix length, written as IP/prefix (e.g., 192.168.1.0/24). The prefix number indicates how many bits of the address represent the network portion. A /24 means the first 24 bits are the network, leaving 8 bits for host addresses, which gives 254 usable hosts.
How do I determine the number of usable hosts in a subnet?
The formula is 2^(32 - prefix length) - 2. The subtraction of 2 accounts for the network address and broadcast address, which cannot be assigned to hosts. For example, a /24 subnet has 2^8 - 2 = 254 usable hosts, while a /30 has 2^2 - 2 = 2 usable hosts.
What is a wildcard mask and when is it used?
A wildcard mask is the inverse of a subnet mask. Where the subnet mask has a 1-bit, the wildcard mask has a 0-bit, and vice versa. For example, the wildcard mask for 255.255.255.0 is 0.0.0.255. Wildcard masks are commonly used in access control lists (ACLs) on Cisco routers and in OSPF configurations.
What are IP address classes and do they still matter?
IP address classes (A, B, C, D, E) were the original method for allocating address ranges. Class A covers 1.0.0.0 to 126.255.255.255, Class B covers 128.0.0.0 to 191.255.255.255, and Class C covers 192.0.0.0 to 223.255.255.255. While CIDR has largely replaced classful networking, understanding classes remains useful for quickly identifying address ranges and for networking exams.
Related Tools
Link to this tool
Copy this HTML to link to this tool from your website or blog.
<a href="https://toolboxkit.io/tools/subnet-calculator/" title="Subnet Calculator - Free Online Tool">Try Subnet Calculator on ToolboxKit.io</a>