IPv4 Subnet Calculator
Every subnet number from one IP and prefix — with the binary math shown, and /31 and /32 handled correctly — entirely on this device.
Type a host count to get the smallest prefix that fits.
Options that would pass /32 are disabled.
| Network address | 192.168.1.128 | |
|---|---|---|
| Broadcast address | 192.168.1.191 | |
| First usable host | 192.168.1.129 | |
| Last usable host | 192.168.1.190 | |
| Usable hosts | 62 | |
| Netmask | 255.255.255.192 | |
| Wildcard mask | 0.0.0.63 | |
| Prefix | /26 | |
| IP class | Class Chistorical | |
| Classification | Private (RFC 1918) | |
first 26 bits network, last 6 bits host
AND the address with the mask → the network address.
OR the network with the wildcard → the broadcast address.
Choose “Split into” to divide this network into equal subnets.
Press ? for shortcuts
Do it offline:$ ipcalc 192.168.1.130/26
How to use it
- Give the field whatever form you have: CIDR such as 10.20.0.0/22, an address followed by a dotted mask, or a bare IP — for a bare address the page assumes /24 and says so instead of guessing silently.
- Read the table of derived values — network, broadcast, first and last usable host, host count, netmask, wildcard — with badges naming any special-purpose range the network falls in.
- Check the binary view when a boundary surprises you: it shows address AND mask and network OR wildcard octet by octet, with the network/host split labeled in words rather than left to be counted.
- Take the numbers with you — every row has its own copy button, Copy JSON captures the whole table, ⌘/Ctrl + S downloads it, and Share folds the current state into the URL fragment.
Type or paste an address with its prefix or mask — 192.168.1.130/26, or the same network as 255.255.255.192 — and every derived number appears at once: network, broadcast, usable range, host count, wildcard. The binary view writes out the AND and OR that produced them, /31 and /32 come out the way the RFCs say, and the math never leaves this device.
How it works
An IPv4 address is 32 bits, and a subnet is a decision about where those bits split: the first n name the network, the remaining 32 − n name hosts inside it. Classless Inter-Domain Routing (RFC 4632) lets the split fall anywhere, which is why exactly 33 prefixes exist — /0 through /32 — and why the slider on this page has 33 stops. Prefix and dotted mask are two spellings of one number: /26 means 26 ones then 6 zeros, which reads 255.255.255.192 in decimal. Subnetting itself is older, introduced by RFC 950 in 1985, but the classless form is the one every modern router speaks.
Every value in the table falls out of three bitwise steps. AND the address with the mask: the host bits vanish, and what remains is the network address. Invert the mask: that is the wildcard, its exact bit-for-bit complement. OR the network with the wildcard: the host bits all become ones, which is the broadcast address. First and last usable host sit just inside those two endpoints, and a standard block holds two-to-the-host-bits minus two hosts — minus two because the all-zeros and all-ones patterns are spoken for. The binary view prints each of these steps so none of it has to be taken on faith.
The minus-two rule has two principled exceptions, and mishandling them is the classic subnet-calculator bug. A /31 leaves a single host bit — two addresses — and RFC 3021 declares both usable on point-to-point links, since a wire with exactly two ends has no one else to broadcast to; numbering router links this way stops half of every /30 from being wasted. A /32 is one address: a host route, the form routing tables and firewall rules use to pin down a single machine. This page reports two usable hosts for the first and a single-address route for the second — never the general formula's meaningless zero or minus two.
The class letter in the table is a fossil, and it is labeled that way. Until 1993 the leading bits of an address dictated its mask — class A meant /8, B meant /16, C meant /24, while D and E were set aside for multicast and experiments. CIDR abolished the rule; the vocabulary survives in certification exams and old configurations, so it is reported here as history, not advice. What still matters operationally is IANA's special-purpose registry: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are private (RFC 1918), 100.64.0.0/10 belongs to carrier-grade NAT (RFC 6598), 127.0.0.0/8 loops back, 169.254.0.0/16 is link-local, and three small blocks exist purely for documentation. The classification badges are that registry, checked against the network address.
Examples
10.0.0.0/8network 10.0.0.0 · broadcast 10.255.255.255 · usable 10.0.0.1 – 10.255.255.254 · 16,777,214 usable hostsHistorically class A, today simply a /8 with 24 host bits. The badge reads Private (RFC 1918), and the host count is 2^24 − 2 = 16,777,214 — the commas are display formatting only, so the copied JSON carries the raw 16777214.
192.168.1.130/26network 192.168.1.128 · broadcast 192.168.1.191 · usable 192.168.1.129 – 192.168.1.190 · 62 usable hostsThe default sample, chosen because the boundary cuts mid-octet: in the fourth octet, 10000010 AND 11000000 = 10000000, so .130 lives in the .128 block rather than .0's. The binary view labels the split first 26 bits network, last 6 bits host instead of asking you to count cells.
500500 hosts need 9 host bits — /23 gives 510 usable addresses.Typed into the Hosts needed field rather than the address box. Eight host bits offer only 254 usable addresses, so the tool rounds up to nine and rewrites the input's suffix to /23 as a visible, undoable edit — the output shown here is the reasoning line the page prints.
10.1.1.0/31network 10.1.1.0 · broadcast 10.1.1.1 · usable 10.1.1.0 – 10.1.1.1 · 2 usable hosts (RFC 3021 point-to-point)A point-to-point link between two routers. RFC 3021 makes both addresses of a /31 usable, because a two-ended wire needs neither a network identity nor a broadcast — calculators that print 0 here are applying the classful formula to a prefix the standards exempt.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
0.0.0.0/0 computes — it is the default route
The whole address space is a legitimate block, so the page calculates it rather than refusing: network 0.0.0.0, broadcast 255.255.255.255, and 4,294,967,294 usable addresses between them. A chip supplies the meaning: 0.0.0.0/0 is the entire IPv4 address space — used as the default route. That is the anything-not-matched-elsewhere entry in every routing table.
255.255.255.255 is the limited broadcast, not a host
The all-ones address is delivered to every interface on the local link and never forwarded off it — RFC 919's limited broadcast. As a /32 it shows 1 address — a single-host route, and its badge names the broadcast role rather than filing it under the reserved 240/4 space that surrounds it.
Class D and E: calculated, flagged, not assignable
Multicast (224.0.0.0/4) and reserved (240.0.0.0/4) blocks subnet like anything else, because addressing is just bit arithmetic. The page does the math and adds the honest flag: Multicast/reserved range — not host-assignable. Multicast groups are joined, not configured onto interfaces, and 240/4 still routes almost nowhere despite periodic proposals to release it.
A leading zero is a security-bug class, not a style choice
BSD-derived parsers read 010.8.8.8 as octal — that is 8.8.8.8, a public resolver — while decimal parsers read 10.8.8.8, a private address. When validation and connection disagree about which address a string names, allow-lists get bypassed; the mismatch produced a cluster of CVEs in address-parsing libraries in 2021. This page refuses the spelling and names the unambiguous one instead of betting on a parser.
/31 against the reserve-two habit
Anyone trained before RFC 3021 support was universal learned to set aside two addresses per subnet, so a two-address block reads as useless. On a point-to-point link the premises do not hold, and the Hosts needed field answers 2 with /31 accordingly — a /30 would deliver the same two usable addresses while consuming twice the space. Keep /30 only for gear too old to comply.
No ipcalc installed? Python already has the math
ipcalc is a one-line package install on most Linux distributions but absent from stock macOS. The standard library covers the gap: python3 -c "import ipaddress; n = ipaddress.ip_network('192.168.1.130/26', strict=False); print(n.network_address, n.broadcast_address, n.num_addresses)" prints the network, the broadcast and the block's total address count. strict=False accepts a host address inside the block, exactly as this page does, and neither route sends a byte anywhere.
Common errors
Octet 2 is 300 — each octet is 0–255- Each dotted number is one byte, so 255 is the ceiling. The message counts octets from 1 and the field highlights the offender — most often two octets fused during a paste, or a transposed digit.
`010` is ambiguous (octal in some parsers) — write `10`- The refusal is deliberate: inet_aton-family parsers treat a leading zero as base 8, so the same text can name two different addresses depending on the library that reads it. The message hands back the decimal spelling this page will accept.
255.0.255.0 is not a valid subnet mask — 11111111.00000000.11111111.00000000 has a 1 after a 0; a mask is contiguous 1s then 0s- A netmask must be unbroken ones followed by unbroken zeros, or it corresponds to no prefix length at all. The dotted binary in the message shows exactly where the ones restart; if your pattern is scattered on purpose, it is an ACL wildcard rather than a netmask, and its complement may be what you meant.
/40 is not a valid prefix — CIDR prefixes run /0 to /32- IPv4 offers 32 bits, so no prefix can be longer. A /40 is usually an IPv6 habit surfacing in an IPv4 field, or a stray digit — the slider stops at /32 for the same reason the parser does.
This looks like an IPv6 address — this calculator is IPv4-only. An IPv6 subnet calculator is planned but not yet available.- Any colon routes here, since no IPv4 form contains one. The note is deliberately a dead end: rather than linking to a page that does not exist yet, the tool says plainly that IPv6 support is planned and absent, and leaves your input untouched while you decide.
FAQ
How many usable hosts does a /24 have?
254. A /24 keeps 8 bits for hosts, which is 256 patterns; the all-zeros pattern is the network address and the all-ones pattern is the broadcast, leaving 254 to assign. The same subtraction gives 65,534 for a /16 and 16,777,214 for a /8, and it holds for every prefix down to /30 — at /31 the accounting changes on purpose.
How do I convert 255.255.255.0 to CIDR notation?
Count the ones: 255.255.255.0 is twenty-four of them, so /24. Likewise 255.255.0.0 is /16, 255.255.255.192 is /26, and 255.255.255.252 is /30. Paste either spelling into the field and the table prints the other; a mask whose ones stop and restart converts to nothing, and the error shows its binary so the break is visible.
What is a wildcard mask and why does Cisco want one?
It is the netmask's bit-for-bit complement — zeros over the network bits, ones over the host bits. A /26's netmask 255.255.255.192 pairs with the wildcard 0.0.0.63. IOS access-list syntax matches on wildcards, where a zero bit means must-match, so the table prints both forms and spares you complementing octets in your head.
Why does a /31 show 2 usable hosts instead of 0?
Because RFC 3021 defines it that way for point-to-point links, and this calculator follows the RFC. The two reserved patterns exist to give a subnet a name and a broadcast; a link with exactly two ends uses neither. Tools that print 0 are extending the classful formula past its domain. If a device genuinely predates RFC 3021, fall back to /30 and accept the waste.
How do I tell whether an address is private or public?
Match it against the RFC 1918 blocks — 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 — which never appear on the public Internet. The badges here run the full IANA special-purpose check automatically, which also catches near-misses people assume are private: 100.64.0.0/10 is carrier-grade NAT space shared by ISPs (RFC 6598), 169.254.0.0/16 is link-local autoconfiguration, and 203.0.113.0/24 exists only in documentation. An address matching no registry row is public.
What prefix fits a given number of hosts?
Add two for the network and broadcast addresses, then round up to a power of two — or type the count into the Hosts needed field and let it search: 500 hosts need 9 host bits, since 2^9 − 2 = 510, so /23; 1,000 need /22, which offers 1,022. The field writes the answer back into the input so the rest of the table follows. Real networks grow — one extra prefix step of headroom is usually cheaper than renumbering.
Keyboard shortcuts
- ⌘/Ctrl + Enter
- Force a recalculation immediately — the page already recomputes as you type, so this is a belt-and-braces rerun.
- ⌘/Ctrl + C
- With focus in the tool and nothing selected, copies the results as JSON; a live selection copies itself, and the two number fields are left alone entirely.
- ⌘/Ctrl + Shift + C
- Copies the results as JSON no matter what selection exists.
- ⌘/Ctrl + S
- Downloads the results as a .json file. Inside this page it overrides the browser's save-page dialog — the help overlay states the conflict.
- t
- Cycle the color theme (ignored while typing in a field, during IME composition, and when single-key shortcuts are disabled).
- ?
- Opens the shortcuts overlay (inactive while typing in a field or during IME composition).
- Esc
- Closes the topmost overlay and hands focus back to whatever opened it. It never clears the input.