Use our free tool — no sign-up required.
IP Subnet Calculator — Free Online ToolHow IPv4 addressing works
An IPv4 address is a 32-bit number written as four decimal octets separated by dots — for example 192.168.1.10. Each octet represents 8 bits, giving values from 0 to 255. In binary, 192.168.1.10 is 11000000.10101000.00000001.00001010.
Every IPv4 address has two parts: the network portion (shared by all hosts in the subnet) and the host portion (unique to each device). The subnet mask defines where that boundary falls.
What is a subnet mask?
A subnet mask is a 32-bit number where all network bits are set to 1 and all host bits are set to 0. When written in dotted decimal, the most common subnet masks look like this:
| CIDR Prefix | Subnet Mask | Network Bits | Host Bits | Total Addresses |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 8 | 24 | 16,777,216 |
| /16 | 255.255.0.0 | 16 | 16 | 65,536 |
| /24 | 255.255.255.0 | 24 | 8 | 256 |
| /25 | 255.255.255.128 | 25 | 7 | 128 |
| /28 | 255.255.255.240 | 28 | 4 | 16 |
| /30 | 255.255.255.252 | 30 | 2 | 4 |
CIDR notation
CIDR (Classless Inter-Domain Routing) expresses the network prefix length as a suffix after the IP address: 192.168.1.0/24. The number after the slash tells you how many bits are in the network portion. /24 means the first 24 bits are fixed (the network) and the remaining 8 bits vary (the hosts).
CIDR replaced the older classful addressing system — Class A (/8), Class B (/16), Class C (/24) — in 1993. It allows far more flexible allocation because any prefix length from /0 to /32 is valid, not just multiples of 8.
How to calculate subnet values from a CIDR prefix
Given an IP address and prefix — for example 192.168.10.50/26 — here is how to derive all subnet values:
Step 1: Calculate the subnet mask
A /26 prefix means the first 26 bits are 1s. In binary: 11111111.11111111.11111111.11000000. In dotted decimal: 255.255.255.192.
Step 2: Find the network address
Apply a bitwise AND between the IP address and the subnet mask. In binary:
- IP:
11000000.10101000.00001010.00110010(192.168.10.50) - Mask:
11111111.11111111.11111111.11000000(255.255.255.192) - AND:
11000000.10101000.00001010.00000000= 192.168.10.0
Step 3: Calculate total addresses and usable hosts
Host bits = 32 − prefix = 32 − 26 = 6. Total addresses = 2^6 = 64. Usable hosts = 64 − 2 = 62 (subtract network and broadcast addresses).
Step 4: Find the broadcast address
Set all host bits to 1. The last octet of the network address is 0 (00000000). Setting 6 host bits to 1: 00111111 = 63. Broadcast address: 192.168.10.63.
Step 5: First and last usable host
- First usable host: network address + 1 = 192.168.10.1
- Last usable host: broadcast address − 1 = 192.168.10.62
Wildcard masks
The wildcard mask is the bitwise complement of the subnet mask — it has 0s where the subnet mask has 1s, and 1s where the subnet mask has 0s. For a /26 mask (255.255.255.192), the wildcard mask is 0.0.0.63.
Wildcard masks are used in Cisco IOS access control lists (ACLs) and OSPF network statements. A 0 bit means "must match", a 1 bit means "ignore". This allows patterns like "match any host in 10.0.0.0/8" or "match this specific host".
Private IP address ranges (RFC 1918)
Three address ranges are reserved for private use and are not routable on the public internet:
| Range | CIDR | Class | Usable Hosts |
|---|---|---|---|
| 10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | A | ~16.7 million |
| 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | B | ~1 million |
| 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | C | ~65,534 |
Devices on private networks access the internet through Network Address Translation (NAT), which maps private addresses to a single public IP address at the router.
Special prefix lengths: /31 and /32
The formula "usable hosts = 2^(32−prefix) − 2" breaks down at the extremes:
- /31: 2 total addresses, 0 usable by the standard formula. However, RFC 3021 allows /31 subnets for point-to-point links — both addresses are assigned to the two endpoints with no network or broadcast address.
- /32: Identifies a single host. Used for loopback addresses, static routes to specific hosts, and firewall rules.
Frequently asked questions
What is CIDR notation?
CIDR (Classless Inter-Domain Routing) expresses an IP address and its network prefix as a single string — for example 192.168.1.0/24. The number after the slash tells you how many bits belong to the network portion. CIDR replaced the older classful system (Class A/B/C) in 1993, allowing far more flexible address allocation.
How many usable hosts does a /24 subnet have?
A /24 subnet contains 256 total addresses (2^8). Two are reserved — the network address and the broadcast address — leaving 254 usable hosts. In general, usable hosts = 2^(32 − prefix) − 2 for prefixes from /1 to /30.
What is the difference between subnet mask and wildcard mask?
The subnet mask uses 1s to mark network bits (e.g. 255.255.255.0). The wildcard mask is its bitwise complement — 0s for network bits and 1s for host bits (e.g. 0.0.0.255). Wildcard masks are standard in Cisco IOS access control lists and OSPF network statements.
What are the private IP address ranges?
RFC 1918 defines three private ranges not routable on the public internet: 10.0.0.0/8 (Class A — up to 16M hosts), 172.16.0.0/12 (Class B — up to 1M hosts), and 192.168.0.0/16 (Class C — up to 65K hosts). Devices on private networks access the internet through NAT.
Conclusion
Subnetting is built on straightforward binary arithmetic. Once you understand that the prefix length defines how many bits are fixed (network) versus variable (host), you can derive every other value — subnet mask, network address, broadcast address, first and last usable host, and wildcard mask — from first principles. Use our free IP Subnet Calculator to get all these values instantly for any IP address and prefix, with a full binary breakdown included.
Ready to calculate your subnet? Try our free tool — works instantly in your browser.
IP Subnet Calculator — Try it Free