Subnet Calculator
Calculate IP ranges, subnet masks, and host counts from CIDR notation
About This Tool
What the Subnet Calculator does
You give it an IPv4 address in CIDR notation, like 192.168.1.0/24 or 10.42.7.99/19, and it shows you the full breakdown of the subnet that address belongs to. The seven things it returns are the network address, the broadcast address, the subnet mask in dotted-decimal form, the first usable host, the last usable host, the total number of usable hosts, and the total number of addresses in the block. There is one input field and no submit button. Type, and the answer is there.
The five address fields each have a Copy button next to them so you can grab the value without selecting it by hand. The two count fields, Usable Hosts and Total Addresses, are shown as plain numbers because they are short and easy to read off.
Who actually needs this
Mostly three kinds of people. Network admins planning or documenting an IP layout: you have a /16 from upstream and you are slicing it into /24s for VLANs, or you inherited a network and want to know where one host's subnet starts and ends. Students working through Cisco, CompTIA Network+, or any networking course: subnetting comes up on every exam and doing it on paper by hand gets old fast. And developers writing firewall rules, VPC configurations, Kubernetes pod CIDRs, or anything else that takes a CIDR and wants to know the human-readable shape of that range.
If you are looking up your own public IP, or trying to figure out who owns an address, this is not the tool for that. This one only does the math on a range you already have. The IP Address Info tool linked at the bottom of the page handles "what is my IP" style questions.
How to use it
One field, labeled "CIDR Notation," with a placeholder of 192.168.1.0/24. Enter an IPv4 address, a forward slash, and a prefix length from 0 to 32. As you type, the Result card appears with the seven fields filled in. If the input is invalid the card simply does not render — there is no error message — so if nothing shows up, the input is the thing to fix.
A few small conveniences worth knowing about:
- You do not have to zero out the host portion. Typing
192.168.1.73/24gives you the same result as192.168.1.0/24because the calculator masks the host bits for you. This is the normal way to find "what subnet does this host live in?" - Results are live, so editing a single digit updates everything immediately.
- The Copy buttons write the raw value to your clipboard — no extra formatting, no trailing whitespace, no quotes.
How it works, plainly
Every result comes from bitwise arithmetic on the 32-bit integer form of the address. An IPv4 address is four octets, each 0–255, packed into one number: octet1 × 2^24 + octet2 × 2^16 + octet3 × 2^8 + octet4. So 192.168.1.0 becomes 3232235776. You do not need to compute that by hand; the only reason to mention it is so the rest makes sense.
The prefix /n means the first n bits of that 32-bit number are the network portion and the remaining 32 − n bits are the host portion. The subnet mask is just "n ones followed by (32 − n) zeros," translated back into four octets. For /24, that is twenty-four 1 bits and eight 0 bits, which spells out 11111111.11111111.11111111.00000000, or 255.255.255.0 in decimal. For /19 it is 255.255.224.0. For /30 it is 255.255.255.252.
Once you have the mask, three operations give you the rest:
- Network address = your IP AND the mask. AND zeroes out every host bit, leaving the first address in the block.
- Broadcast address = the network OR the inverted mask. OR with the inverted mask sets every host bit to 1, giving the last address in the block.
- First usable host = network + 1. Last usable host = broadcast − 1.
Counts come from one formula: total addresses = 2^(32 − prefix). A /24 has 256, a /20 has 4,096, a /16 has 65,536, a /8 has 16,777,216. Usable hosts equal that total minus 2, because the network address and the broadcast address cannot be assigned to a device.
The /31 and /32 special case
For /31 and /32 the calculator does not subtract those two reserved addresses. A /31 reports 2 usable hosts and a /32 reports 1. There is a reason for this and it is not a bug.
A /31 has only two addresses to begin with. If you subtracted the network and broadcast addresses the usual way you would be left with zero usable hosts and the prefix would be useless. RFC 3021 redefined /31 for point-to-point links — typically router to router on a serial or transit link — so that both addresses serve as host endpoints and no broadcast is reserved. The two routers each take one of the two addresses and talk directly. This is how most modern point-to-point links are addressed now, because it saves half the address space compared to the older /30 convention.
A /32 is a single address, used for things like loopback interfaces, host routes, or specifying one exact endpoint in a firewall rule. There is no range to break out, so "1 usable host" is the only sensible answer.
For both /31 and /32 the calculator also makes the first and last usable host equal to the network and broadcast addresses themselves, since the subtract-one trick does not apply.
A worked example: 10.0.4.137/22
Suppose you have a host with IP 10.0.4.137 in a /22 subnet and you want to know the range. Type 10.0.4.137/22 into the box. Here is what comes back and why.
The prefix /22 means 22 network bits and 10 host bits. The mask is 255.255.252.0. ANDing your IP with that mask clears the bottom 10 bits, which spans the last octet entirely and the bottom 2 bits of the third octet. 10.0.4.137 becomes 10.0.4.0 as the network address.
The broadcast address is the network with all 10 host bits set: 10.0.7.255. The block runs from 10.0.4.0 to 10.0.7.255 inclusive, which is 1,024 addresses (2^10). Usable hosts: 1,022. First usable: 10.0.4.1. Last usable: 10.0.7.254.
If you had typed 10.0.4.0/22, 10.0.5.99/22, or 10.0.7.200/22, you would get the exact same Result card, because every one of those addresses belongs to the same /22 block.
Picking the right prefix for a target host count
The everyday question is "I need to fit N hosts, what prefix do I use?" The procedure is the same every time:
- Add 2 to your host count to account for the reserved network and broadcast addresses.
- Find the smallest power of two that is at least that big.
- The exponent of that power of two is your host-bit count. The prefix is
32 − that exponent.
A few common results worth knowing by feel:
- Up to 2 hosts (point-to-point): /30 (4 addresses, 2 usable) or /31 (2 addresses, both usable under RFC 3021).
- Up to 6: /29.
- Up to 14: /28.
- Up to 30: /27.
- Up to 62: /26.
- Up to 126: /25.
- Up to 254: /24.
- Up to 510: /23.
- Up to 1,022: /22.
- Up to 65,534: /16.
Always go one size larger than you think you need. Subnets are sticky once devices, DHCP scopes, and firewall rules are deployed; resizing later costs more than wasting a few addresses up front.
Common pitfalls
Nothing shows up. The Result card only renders when the input is parseable. The four checks are: there is exactly one slash, the part before it splits into four numeric octets, every octet is 0–255, and the prefix is 0–32. 192.168.1.300/24 fails (octet over 255). 192.168.1.1/33 fails (prefix over 32). 192.168.1.1 fails (no slash). 192.168.1/24 fails (only three octets). There is no error toast — just a missing card.
Confusing total addresses with usable hosts. They differ by 2 on every normal prefix. The tool shows both deliberately. If you are sizing a DHCP pool, use usable hosts. If you are reasoning about route table entries or address space accounting, total addresses is the figure that matters.
Assuming /24 boundaries everywhere. A /22 covers four consecutive /24s starting at a multiple of 4 in the third octet (0, 4, 8, 12, …). A /23 covers two consecutive /24s starting at an even number. 10.0.5.0/22 is the same block as 10.0.4.0/22; 10.0.6.0/22 is also the same block. People often expect the network address to be the IP they typed; it is the IP they typed with the host bits masked off, which often lands somewhere else.
Treating /31 as broken. If you see "Usable Hosts: 2" for a /31 and "1" for a /32, that is correct, not a glitch. See the section above on RFC 3021.
When this is not the right tool
IPv6. CIDR works the same way conceptually for IPv6, but the addresses are 128 bits long and written in hex, like 2001:db8::/32. This calculator parses four dotted-decimal octets and a prefix of 0–32; an IPv6 address will fail the parse and produce no result. There is no IPv6 mode.
VLSM (variable-length subnet masking) plans across many subnets. This tool answers questions about one CIDR at a time. If you are slicing a /16 into nine differently sized subnets and need to lay them out without overlap, you will end up running the calculator nine times and tracking the result on paper, which works but is tedious. A dedicated VLSM planner is faster for that workflow.
Reverse questions like "what prefix do these two IPs share?" or "what is the smallest CIDR that covers this range?" The calculator goes from CIDR to range, not range to CIDR. You can answer those by hand by XORing the two endpoints and counting the leading zeros in the result, but that is its own workflow.
Anything involving real-world assignment policy. This tool tells you what is mathematically usable. It does not know that your gateway lives at .1, that .254 is your firewall, that you reserve .2–.10 for infrastructure, or that DHCP starts at .100. Layer those constraints on top yourself.
Quick reference for the special addresses
It helps to know what each of the seven outputs is actually used for:
- Network address — identifies the subnet itself. Used in routing tables and ACLs. Never assigned to a device.
- Broadcast address — sends a packet to every host on the subnet at once. Used by ARP, DHCP discovery, and some legacy protocols. Never assigned to a device.
- Subnet mask — the dotted-decimal form many OS network configuration dialogs ask for instead of a prefix.
/24and255.255.255.0are the same statement. - First usable host — by convention often the default gateway, though nothing forces this.
- Last usable host — sometimes used for the gateway in environments that prefer counting down; otherwise just another assignable address.
- Usable hosts — the count you compare against your device inventory.
- Total addresses — the size of the block, useful for capacity planning and for confirming a subnet aligns to a power-of-two boundary.
Adjacent concepts worth a paragraph each
Private vs public ranges. The calculator does not flag this, but three IPv4 ranges are reserved by RFC 1918 for private use: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. These are the ones you see inside home networks, corporate LANs, and cloud VPCs. The math is identical whether the block is private or public.
Classful addressing. Before CIDR there were fixed classes: Class A was /8, Class B was /16, Class C was /24. CIDR replaced this in 1993 because the fixed sizes wasted huge amounts of address space. The terms still drift into conversation, but in practice every modern network is described by an explicit prefix length, not a class.
Supernetting. The opposite of subnetting. Two adjacent /24s that share the upper 23 bits can be expressed as one /23 in a routing table. Aggregating routes this way is the whole reason CIDR exists and is why BGP works at internet scale.
The 169.254.0.0/16 range. Link-local addresses. If a device cannot reach a DHCP server it may self-assign something in this block. Seeing one means "this host did not get a real address."
If the result looks wrong
Three things to check before assuming the tool is broken. First, copy the network and broadcast addresses out and confirm they bracket your IP — if your IP is 10.0.5.99 and the network is 10.0.4.0 with broadcast 10.0.7.255, you are inside the block. Second, confirm the prefix matches what you intended; off-by-one errors between /23 and /24, or /22 and /23, are easy to make and double the block size each step. Third, check that you did not accidentally enter the mask in dotted-decimal where a prefix length goes (192.168.1.0/255.255.255.0 will not parse — only 192.168.1.0/24 works).
If you have done all three and the numbers still surprise you, the most common culprit is misreading the third octet on /22, /21, /20, or /19 prefixes, where the network and broadcast addresses are not the ones you would have guessed from looking only at the IP. That is the calculator doing its job correctly.
The about text and FAQ on this page were drafted with AI assistance and reviewed by a member of the Coherence Daddy team before publishing. See our Content Policy for editorial standards.