Random IPv6 Address Set Generator
Generate unique IPv6 addresses inside a caller-supplied prefix in canonical compressed and expanded forms.
Description
Generate unique IPv6 addresses within a supplied prefix, returning compressed and expanded forms.
An IPv6 prefix fixes the leading address bits while the remaining bits identify positions within its span. The prefix can be derived from any address in the block by clearing its host bits.1
The output result has prefix as normalized network/prefixLength text and addresses as compressed/expanded string pairs. Compressed formatting follows the repository’s RFC 5952 compressor; each pair encodes the same 128-bit value.2
All positions in the mathematical prefix are eligible, including its first and last addresses. Selection does not check reservations, actual interface assignments, address availability, or reachability.
When to use Random IPv6 Address Set Generator
Use it for IPv6 address-format fixtures or a synthetic set constrained to a caller-selected prefix.
How to use Random IPv6 Address Set Generator and understand its results
- Enter prefixAddress as an IPv6 address without a slash suffix, integer prefixLength from zero through 128, and integer addressCount from 1 through 1,000.
- Ensure the count does not exceed 2^(128 − prefixLength), then run. Host bits in prefixAddress are normalized away.
- Read result.prefix and the compressed/expanded pairs in result.addresses. Keep the strings intact and use the form required by the receiving parser.
hostBits = 128 − prefixLength; hostMask = 2^hostBits − 1; candidate = network OR (random128 AND hostMask) Eight draws sample 16-bit groups for each candidate, using BigInt to preserve all address bits.
On collision, the implementation increments the candidate’s host portion, wrapping it within the host mask and preserving the network bits until it finds an unused value. It then formats expanded text and compresses it. Collision probing consumes no additional random draws.
The capacity check ensures there are enough distinct positions in the prefix. Uniqueness is tracked only within this call; incrementing collisions is not ideal uniform sampling without replacement.
{
"input": {
"prefixAddress": "2001:db8::",
"prefixLength": 64,
"addressCount": 3
},
"randomDraw": 0.25,
"output": {
"result": {
"addresses": [
{
"compressed": "2001:db8::4000:4000:4000:4000",
"expanded": "2001:0db8:0000:0000:4000:4000:4000:4000"
},
{
"compressed": "2001:db8::4000:4000:4000:4001",
"expanded": "2001:0db8:0000:0000:4000:4000:4000:4001"
},
{
"compressed": "2001:db8::4000:4000:4000:4002",
"expanded": "2001:0db8:0000:0000:4000:4000:4000:4002"
}
],
"prefix": "2001:db8::/64"
}
}
} A /128 accepts count one only and returns the supplied address, still consuming eight valid draws. A /127 has two positions. Invalid address syntax, infeasible counts, invalid draws, and counts above 1,000 fail.
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.
The generator does not exclude subnet-router anycast or other reserved values, implement interface-identifier privacy schemes, assign addresses, discover used hosts, or guarantee operational suitability.
Separate runs can overlap. Probing biases the distribution when random candidates collide; choose another sampling method when ideal subset statistics are required.
Alternative or Complementary methods
Inspect a supplied prefix with the subnet calculator before generating fixtures. A compressor formats an existing address without sampling.
References
-
RFC 4291: IP Version 6 Addressing Architecture — IETF, RFC Editor
-
RFC 5952: A Recommendation for IPv6 Address Text Representation — IETF, RFC Editor
Similar or alternative tools
- IPv6 Subnet Calculator
Inspect prefix bounds and exact capacity.
- IPv6 Address Compressor
Canonicalize an existing IPv6 address.