GenerateRandomSearch

Subnet Calculator

A /24 is 256 addresses and 254 usable, and almost everyone carries two rules away from that: take two off, and the last one is the broadcast address. Both are false at /31 and at /32, and a security group or a route written on the wrong assumption does not throw an error — it simply fails to match, and something is unreachable for an afternoon. This computes what a block actually holds, splits it into subnets that tile it exactly, and states which rule it used and why.

What this generator does

Derives every fact about an IPv4 block from the two numbers that define it — network address, broadcast, mask, wildcard, usable range and host count — then divides it into equal subnets and answers the reverse question of what prefix a host count needs. The IP address generator already here invents plausible addresses; this one reasons about ranges, and can draw an address guaranteed to be inside one, which is the difference between a fixture that tests your rule and a fixture that quietly does not.

How to use this tool

  1. Enter a block in slash notation, or with an explicit dotted mask.
  2. Press Work out the block.
  3. Set a longer prefix to see how it divides.
  4. Use the host box to find the smallest block that fits a given number of machines.

Understanding the controls

CIDR block
Slash notation (192.168.1.0/24) or an explicit dotted mask (192.168.1.0/255.255.255.0). A host address with a prefix is read as the block containing it, so 192.168.1.130/24 gives 192.168.1.0/24 — which is what the notation means, and a common source of confusion when a router shows one and a config file the other.
Split it into blocks of
A prefix at least as long as the block's own. The subnets produced are contiguous, non-overlapping, and cover the parent exactly — so a plan built from them cannot leave a gap that gets assigned twice.
What size do I need for this many hosts?
Counts assignable addresses rather than total ones, which is where the off-by-two bites: 300 machines need a /23, because a /24 offers 254 usable and not 256.
Draw a test address
Picks a random assignable address from inside the block — never the network or broadcast address. The only random thing on the page, and it exists so a test fixture is genuinely inside the range under test.

Worked examples

192.168.1.0/24
256 addresses, 254 usable, .1 to .254, broadcast .255. The one everybody knows.
10.0.0.0/31
Two usable addresses, not zero. RFC 3021 defines /31 for point-to-point links precisely so a router does not waste half its space on a broadcast address it will never use.
A /24 split into /26s
.0, .64, .128 and .192 — four blocks that cover the parent exactly, with nothing left over and nothing counted twice.
300 hosts
A /23. A /24 gives 254 usable, which is the answer people reach for and it does not fit.

Common use cases

  • Checking the usable range before writing a firewall or security-group rule
  • Splitting an allocated block into per-environment or per-availability-zone subnets
  • Working out what size block a given number of machines actually needs
  • Confirming whether an address falls inside a range during an incident
  • Drawing a test address from inside a range for a fixture that must genuinely match

How this generator works

Dotted quads are only a display format. Everything is computed on unsigned 32-bit integers: the mask is a prefix of ones, the network address is the input masked, the broadcast address is the network with the host bits set, and containment is a masked comparison. Splitting a block is arithmetic on a contiguous range, which is why the subnets are guaranteed to tile the parent rather than merely appearing to. JavaScript's bitwise operators return signed 32-bit results, so every one of them is followed by an unsigned shift — without it a masked address comes back negative and formats as nonsense, which is the single likeliest defect in a tool like this, and the reason the tests drive all thirty-three prefix lengths rather than a sample of them.

Randomness and fairness

The arithmetic is entirely deterministic — a block always yields the same facts, and the same split. Randomness appears in exactly one place and only when you ask for it: the draw-a-test-address button, which uses the browser's cryptographic random number generator and is constrained to the assignable addresses of the block.

For how randomness is produced across the whole site, see how Generate Random works.

Assumptions this tool makes

  • The usual convention that the first and last addresses of a block are reserved, except at /31 and /32 where it does not apply. Some equipment can be configured otherwise, and where it is, the usable count will differ.

Limitations and good to know

  • IPv4 only. IPv6 is not a wider version of the same thing — it has no broadcast address, no comparable usable-host convention, and 128-bit arithmetic that cannot be held in a JavaScript number — so it is declined rather than half implemented.
  • The subnet list is cut at 64 rows on screen. The total is always reported honestly alongside it, and the truncation is stated rather than presented as the complete answer.
  • Variable-length subnetting — dividing a block into subnets of several different sizes — is not offered. Every split here is into equal parts.
  • It knows nothing about your network. Whether an address is actually free, routable or already assigned is not something a calculator can tell you.

Common mistakes

Applying 'subtract two' at /31
A /31 has two usable addresses, not zero. RFC 3021 assigns both ends of a point-to-point link and reserves neither, which is why it exists at all. The page states which rule it applied for whatever prefix you entered.
Sizing a subnet by total addresses
Size it by assignable ones. Three hundred machines do not fit a /24's 256 addresses, and they would not fit even if the count were exact — 254 is the number that matters, and the host box uses it.
Assuming a host address and its block are interchangeable
192.168.1.130/24 names the block 192.168.1.0/24, not an address with a mask attached. This tool normalises it and shows the block, which is what the notation means everywhere it is used.

Practical tips

  • Split before you allocate. Working out the four /26s of a /24 up front is much easier than discovering a gap after three of them are in use.
  • Use the draw-a-test-address button for fixtures. An address you invented by hand is one edit away from being outside the range your rule is supposed to match, and the test will still pass.
  • Check the wildcard mask if you are writing access lists — several vendors want the inverse rather than the mask, and reading it off is quicker than working it out.

Troubleshooting

It will not accept my block
It wants a dotted quad and a prefix, or a dotted quad and a contiguous mask. A mask with a hole in it — 255.255.0.255 — is refused, because it does not describe a contiguous range and treating it as one would produce a block with gaps in it.
The subnet list stops before the end
It is cut at 64 rows for display. The total count above it is the real figure, and all of them tile the parent — the cut is a display limit, not a different answer.

Privacy and your data

The block you type never leaves your browser. Nothing is uploaded, no lookup is performed against any registry or DNS, and nothing is written into the page address — which matters because internal ranges are the sort of thing that should not end up in a shared browser history or a referrer header.

Frequently asked questions

Why does a /31 have two usable addresses?
Because RFC 3021 says so, and for a good reason. On a point-to-point link there are exactly two ends and no need for a broadcast address, so reserving one would waste half the block. Before /31 was defined, links like these used /30 and threw away two addresses out of every four.
How many hosts fit in a /22?
1,024 addresses and 1,022 usable. Each step of one in the prefix doubles the block, so /24 is 256, /23 is 512, /22 is 1,024 — and two come off each of them for the network and broadcast addresses.
Can I split a block into different-sized subnets?
Not with this tool — every split here is into equal parts. Variable-length subnet masking is a genuinely different problem, because the order you allocate in determines whether the sizes you want fit at all, and a calculator that returned one arrangement without saying so would be misleading.
Does it support IPv6?
No, and deliberately. IPv6 has no broadcast address, so the usable-host arithmetic that most of this page is about does not carry over, and its 128-bit addresses cannot be held exactly in a JavaScript number. An IPv6 tool needs different arithmetic and different explanations, and pretending one tool does both would get the interesting cases wrong.