How to Calculate a Subnet Mask (With a Full CIDR Chart)
Subnetting has a reputation for being hard. It isn't. It has a reputation for being hard because it is almost always taught in binary first, and binary is the slowest possible way to understand it.
Here is the whole thing in one sentence: a subnet mask draws a line through an IP address, and everything left of the line is the network, everything right of it is the host. That's it. Every other rule in this guide is a consequence of that one idea.
If you just need the answer right now, open the free FileNaut Subnet Calculator, type your IP, pick the CIDR from the dropdown, and hit Calculate — you'll get the network address, broadcast address, subnet mask and usable host range instantly. It runs entirely in your browser, so nothing about your network topology is sent anywhere.
If you want to actually understand it — or you're sitting a CCNA exam where no calculator is allowed — the rest of this guide shows you how to do it by hand in about ten seconds using the block-size method, with a full CIDR chart you can bookmark.
What a Subnet Mask Actually Does
An IPv4 address is 32 bits, written as four decimal numbers (octets) from 0 to 255. 192.168.1.130 is really this:
192 168 1 130
11000000.10101000.00000001.10000010
A subnet mask is also 32 bits, but with a strict rule: all the 1s come first, then all the 0s. Never mixed. The mask 255.255.255.192 is:
255 255 255 192
11111111.11111111.11111111.11000000
└──────────── 26 ones ────────┘└ 6 zeros ┘
Because there are 26 ones, we call this a /26. That's CIDR notation — it's just a count of the 1 bits, and it saves you writing the mask out in full.
The ones mark the network portion: the part every device on this subnet shares. The zeros mark the host portion: the part that changes from device to device. More ones means a bigger network prefix and therefore a smaller subnet with fewer hosts. This trips everyone up at first — a /30 is tiny and a /8 is enormous.
Read Any Subnet Mask in 30 Seconds
Because the 1s always come first, an octet in a subnet mask can only ever be one of nine values. Memorise this table and you can read any mask instantly:
| Decimal | Binary | Bits borrowed | Block size |
|---|---|---|---|
| 0 | 00000000 | 0 | 256 |
| 128 | 10000000 | 1 | 128 |
| 192 | 11000000 | 2 | 64 |
| 224 | 11100000 | 3 | 32 |
| 240 | 11110000 | 4 | 16 |
| 248 | 11111000 | 5 | 8 |
| 252 | 11111100 | 6 | 4 |
| 254 | 11111110 | 7 | 2 |
| 255 | 11111111 | 8 | 1 |
Block size = 256 − the mask octet. That single formula is the whole shortcut, and it's what the next section is built on. A mask octet of 192 gives a block size of 64. A mask octet of 240 gives a block size of 16.
How to Calculate a Subnet by Hand (The Block-Size Method)
Let's do 192.168.1.130/26 without touching binary.
- Write the mask. /26 = 8 + 8 + 8 + 2 bits. The first three octets are full (255), the fourth has 2 bits borrowed = 192. So the mask is
255.255.255.192. - Find the block size. 256 − 192 = 64. Your subnets start every 64 addresses in the last octet: 0, 64, 128, 192.
- Find the network address. Which block does .130 fall into? It's between 128 and 191, so the network is
192.168.1.128. - Find the broadcast address. It's the last address in the block — one below the next block start. Next block starts at 192, so broadcast is
192.168.1.191. - Find the usable host range. Everything between the two, exclusive:
192.168.1.129to192.168.1.190. - Count the hosts. 64 addresses in the block, minus the network and broadcast = 62 usable hosts.
Six steps, no binary, about ten seconds once you've done it twice. Check yourself against the subnet calculator — enter 192.168.1.130 with /26 and you should get exactly those numbers back.
The general formulas, if you prefer them written out:
Total addresses = 2 ^ (32 − CIDR)
Usable hosts = 2 ^ (32 − CIDR) − 2
Block size = 256 − (last non-255 mask octet)
Number of subnets when splitting = 2 ^ (bits borrowed)How to Calculate a Subnet Instantly (Online)
By hand is good for learning and for exams. For actual work — sizing a VPC, writing a firewall rule, sanity-checking a colleague's diagram — use a calculator and move on.
- Open the free FileNaut Subnet Calculator.
- Type any IP address in the network into the IP Address field — it doesn't have to be the network address itself.
10.0.5.77works just as well as10.0.0.0. - Choose your prefix from the CIDR Mask dropdown, anywhere from /1 to /32.
- Click Calculate.
- Read off the network address, broadcast address, subnet mask, usable host count and full host range.
It's client-side JavaScript, so your addressing scheme is never uploaded — worth caring about, because internal IP ranges are exactly the kind of detail you shouldn't be pasting into a random website. Nothing to install, nothing to sign up for, and it works the same on a phone as on a laptop.
Full CIDR Chart (/8 to /32)
The reference table. Wildcard masks are included because ACLs on Cisco gear and some cloud firewall rules want the inverse mask rather than the subnet mask.
| CIDR | Subnet mask | Total addresses | Usable hosts | Wildcard |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 | 0.255.255.255 |
| /12 | 255.240.0.0 | 1,048,576 | 1,048,574 | 0.15.255.255 |
| /16 | 255.255.0.0 | 65,536 | 65,534 | 0.0.255.255 |
| /20 | 255.255.240.0 | 4,096 | 4,094 | 0.0.15.255 |
| /21 | 255.255.248.0 | 2,048 | 2,046 | 0.0.7.255 |
| /22 | 255.255.252.0 | 1,024 | 1,022 | 0.0.3.255 |
| /23 | 255.255.254.0 | 512 | 510 | 0.0.1.255 |
| /24 | 255.255.255.0 | 256 | 254 | 0.0.0.255 |
| /25 | 255.255.255.128 | 128 | 126 | 0.0.0.127 |
| /26 | 255.255.255.192 | 64 | 62 | 0.0.0.63 |
| /27 | 255.255.255.224 | 32 | 30 | 0.0.0.31 |
| /28 | 255.255.255.240 | 16 | 14 | 0.0.0.15 |
| /29 | 255.255.255.248 | 8 | 6 | 0.0.0.7 |
| /30 | 255.255.255.252 | 4 | 2 | 0.0.0.3 |
| /31 | 255.255.255.254 | 2 | 0 * | 0.0.0.1 |
| /32 | 255.255.255.255 | 1 | 0 * | 0.0.0.0 |
* /31 and /32 are special cases — see the next section. The intermediate prefixes (/9–/11, /13–/15, /17–/19) follow the same halving pattern; the calculator covers every value from /1 to /32.
Why You Always Lose Two Addresses (And the Two Exceptions)
In a /24 there are 256 addresses but only 254 usable ones, because two are reserved:
- The network address — all host bits set to 0. It names the subnet itself (
192.168.1.0). You can't assign it to a device. - The broadcast address — all host bits set to 1. Traffic sent here goes to every host on the subnet (
192.168.1.255). Also unassignable.
Hence usable = total − 2 for every ordinary subnet. But there are two prefixes where that formula breaks down:
- /31 — point-to-point links. A /31 has only 2 addresses, so subtracting 2 leaves zero, which would make it useless. RFC 3021 (published in 2000) specifically allows both addresses in a /31 to be used as hosts on a point-to-point link, where there's no need for broadcast. Modern routers support this and it halves the address waste versus the old /30 convention. If you see a /31 on a router-to-router link, it isn't a mistake.
- /32 — a single host. One address, no network/broadcast concept at all. You'll see /32 constantly in firewall rules, route tables and allow-lists — it's how you say "this exact IP and nothing else".
Rule of thumb: the −2 applies from /1 through /30. Below that, you're in special-case territory.
Splitting a Network Into Subnets
The other half of subnetting is dividing a block you already own. Say you've been given 192.168.1.0/24 and you need four separate networks — one each for staff, guests, VoIP phones and servers.
You need 4 subnets, and 2² = 4, so you borrow 2 bits from the host portion: /24 + 2 = /26. Block size is 256 − 192 = 64, so the boundaries land every 64 addresses:
| Subnet | Network | Usable range | Broadcast |
|---|---|---|---|
| Staff | 192.168.1.0/26 | .1 – .62 | 192.168.1.63 |
| Guests | 192.168.1.64/26 | .65 – .126 | 192.168.1.127 |
| VoIP | 192.168.1.128/26 | .129 – .190 | 192.168.1.191 |
| Servers | 192.168.1.192/26 | .193 – .254 | 192.168.1.255 |
Four subnets, 62 usable hosts each. Size from the requirement backwards: pick the smallest prefix that still fits your largest segment, then round down. Need 100 devices on one VLAN? A /26 (62 hosts) is too small — go to /25 (126 hosts). Need 12 devices? /28 gives you 14 and wastes almost nothing.
Real networks aren't usually split evenly, and that's fine — VLSM (Variable Length Subnet Masking) just means using different prefix lengths inside the same parent block. A /24 can hold one /25, one /26 and two /27s quite happily, as long as none of them overlap.
The Private IP Ranges Worth Knowing
These blocks (defined in RFC 1918) are reserved for internal use and are never routed on the public internet — which is why almost every home and office network uses one:
| Block | Range | Addresses | Typically used by |
|---|---|---|---|
| 10.0.0.0/8 | 10.0.0.0 – 10.255.255.255 | 16,777,216 | Large enterprise, cloud VPCs |
| 172.16.0.0/12 | 172.16.0.0 – 172.31.255.255 | 1,048,576 | Mid-size networks, Docker defaults |
| 192.168.0.0/16 | 192.168.0.0 – 192.168.255.255 | 65,536 | Home routers, small office |
Two more you'll bump into: 169.254.0.0/16 is link-local (an address in this range means DHCP failed — that's the classic "self-assigned IP" problem), and 100.64.0.0/10 is carrier-grade NAT space, which is why some ISP connections can't accept inbound port forwards.
Note that 172.16.0.0/12 stops at 172.31.255.255, not 172.255.255.255. That one catches people out constantly — 172.32.0.0 is public address space.
Common Subnetting Mistakes
| Symptom | Likely cause | Fix |
|---|---|---|
| Two devices on the same switch can't reach each other | Different subnets, or mismatched masks on the two hosts | Check both masks match. .10/24 and .10/25 disagree about who is local. |
| "Invalid gateway" or gateway unreachable | Gateway sits outside the subnet you configured | The gateway must fall inside the usable host range — run the IP through the calculator and confirm. |
| A device won't accept the IP you assigned | You assigned the network or broadcast address | Use an address strictly between the two. |
| Cloud VPC rejects your CIDR | Provider prefix limits (AWS VPCs accept /16 to /28) | Resize within the provider's allowed range. |
| Subnets "overlap" error | Two blocks share addresses — easy with mixed prefixes | Calculate each network and broadcast address and check no ranges intersect. |
| VPN can't reach the remote LAN | Both sides use 192.168.1.0/24 | Renumber one side. Pick something unlikely, e.g. 192.168.87.0/24. |
Tips
- Memorise the nine mask octets, not the whole chart. 0, 128, 192, 224, 240, 248, 252, 254, 255. Everything else derives from them.
- Block size is the only formula you need under pressure. 256 minus the interesting octet. Networks start at multiples of it.
- Count backwards from the next network. The broadcast address is always one below the start of the next block — far quicker than working it out from binary.
- Size up, not tight. A subnet that's exactly big enough today is a renumbering project in eighteen months. Going one prefix wider is nearly free.
- Avoid 192.168.0.0/24 and 192.168.1.0/24 for anything that will ever be VPN'd. They're the two most common home defaults, so they collide constantly.
- Write CIDR, not dotted masks, in documentation.
/26is unambiguous;255.255.255.192invites transcription errors. - Sanity-check every subnet plan with a calculator before it goes into config. Ten seconds in the subnet calculator beats an outage caused by an off-by-one broadcast address.
FAQs (8)
What is a subnet mask in simple terms? ▼
255.255.255.0 (a /24) means the first three numbers identify the network and only the last number identifies the device.How do I calculate a subnet mask from a CIDR number? ▼
11000000 = 192, giving 255.255.255.192. Faster method: full octets first (26 ÷ 8 = 3 remainder 2, so three 255s), then take the leftover bits from the octet table — 2 bits = 192. Or just use the subnet calculator.How many hosts are in a /24? ▼
x.x.x.0) and the broadcast address (x.x.x.255). The general formula is 2^(32−CIDR) − 2, so a /25 gives 126, a /26 gives 62, and a /28 gives 14.Which is bigger, a /16 or a /24? ▼
What is the difference between a subnet mask and a wildcard mask? ▼
255.255.255.192 becomes the wildcard 0.0.0.63. Cisco access control lists and some routing protocol statements expect the wildcard form; interface configuration expects the subnet mask.Why does a /30 only give me 2 usable addresses? ▼
Does subnetting work the same way in IPv6? ▼
Is it safe to use an online subnet calculator? ▼
Ready to try it?
Use the tool right now — free, no signup, no upload.