Random IPv4 Host Set Generator
Select unique IPv4 addresses from a supplied CIDR block under an explicit boundary-address convention.
Description
Select unique IPv4 addresses from a supplied CIDR block under an explicit boundary-address convention.
A CIDR block fixes the leading bits of IPv4 addresses. Its lowest and highest positions bound the block, while a host-range convention determines whether those positions are eligible for a host-selection fixture.1
Set includeBoundaryAddresses true to sample the entire span, or false to use the CIDR calculator’s firstHost–lastHost range. The output addresses are unique dotted-decimal strings, and cidr identifies the normalized network prefix.
The calculator keeps both /31 endpoints under its point-to-point convention and the single /32 address. Thus false does not remove the endpoints in those two cases.2
When to use Random IPv4 Host Set Generator
Use it for IPv4 parser fixtures or a synthetic unique-address list within one explicitly selected subnet.
How to use Random IPv4 Host Set Generator and understand its results
- Enter address as plain dotted-decimal text, integer prefix from zero through 32, integer hostCount from 1 through 1,000, and includeBoundaryAddresses explicitly.
- Run with a count no larger than the eligible range. The input address may be any address inside the block; it need not already be the network address.
- Read cidr and addresses. Use them as synthetic positions and verify actual availability separately before assigning real hosts.
eligible size = end − start + 1; index = floor(randomDraw × remainingSize) One draw is used per selected address. Start/end come from the full endpoints or calculator host range according to the flag.
A sparse-map Fisher–Yates selection samples without replacement: the chosen remaining index maps to an address offset, its slot is replaced by the last remaining offset, and remaining size decreases. This avoids enumerating the entire subnet.
Selected offsets are added to the starting integer address and formatted through the integer-to-IPv4 converter. With independent uniform draws, every eligible remaining address has equal probability; output order is draw order, not numeric order.
{
"input": {
"address": "192.168.1.77",
"prefix": 24,
"hostCount": 3,
"includeBoundaryAddresses": false
},
"randomDraw": 0.25,
"output": {
"addresses": [
"192.168.1.64",
"192.168.1.254",
"192.168.1.253"
],
"cidr": "192.168.1.0/24"
}
} A /32 permits one selected address with either flag. A /31 permits both. Requesting more than the eligible capacity, malformed IPv4 text, prefixes outside 0–32, counts above 1,000, or invalid draws fails.
Limitations and assumptions
The default source is Math.random; no seed input or cryptographic entropy guarantee is provided. Repeated runs may select the same result, and the distribution depends on the random source.
There is no allocation, DHCP, DNS, live-host lookup, address assignment, or reachability test. Reserved, special-purpose, or already used addresses are not filtered; separate runs can overlap.
Alternative or Complementary methods
Inspect the supplied block with the CIDR calculator. A subnet-exercise generator provides unrelated address/prefix questions and computed answers instead of one constrained unique set.
References
-
RFC 4632: Classless Inter-domain Routing — IETF, RFC Editor
-
RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links — IETF, RFC Editor
Similar or alternative tools
- IPv4 CIDR Calculator
Check the normalized block and eligible host-range convention.
- Random IPv4 Subnet Exercise Generator
Generate address-and-prefix questions with answer keys.