Random IPv6 Subnet Exercise Generator
Generate IPv6 address and prefix questions with exact network, range, host-bit, and address-count answers.
Description
Generate IPv6 subnet questions with exact network bounds and address counts as decimal text.
An IPv6 address contains 128 bits, and a prefix length identifies how many leading bits belong to the network portion. The remaining bits determine the address span. IPv6 does not use broadcast addresses.1
Each result.exercises item has address, prefixLength, and answer. The question address is compressed text; answer uses expanded address forms and includes networkAddress, firstHost, lastHost, hostBitCount, hostCountText, and prefixLength.
firstHost here is the prefix’s lowest address, not a promise of an assignable interface address. hostCountText describes the full mathematical span without subtracting reserved addresses or an IPv4-style broadcast.
When to use Random IPv6 Subnet Exercise Generator
Use it for IPv6 prefix-mask exercises or exact large-count fixtures with an included answer key.
How to use Random IPv6 Subnet Exercise Generator and understand its results
- Enter integer exerciseCount from 1 through 256 and ordered integer minimumPrefix and maximumPrefix from zero through 128.
- Run and present address plus prefixLength as the question; keep answer separate for checking.
- Read hostCountText as exact decimal text. Keep it as text or parse it with arbitrary-precision integers rather than rounding large counts into an ordinary number.
address groups = floor(65536 × randomDraw); prefix = minimumPrefix + floor(randomDraw × (maximumPrefix − minimumPrefix + 1)) Eight draws build the 128-bit address and a ninth chooses the inclusive prefix length.
hostBitCount = 128 − prefixLength; hostCountText = decimal(2^hostBitCount) BigInt masking clears the host bits for the first address and sets them for the last; the subnet calculator returns exact counts and expanded strings.
The generated address is compressed with the repository’s IPv6 compressor before the subnet calculator builds the answer. Addresses are sampled across all 128-bit patterns without an allocation or address-type filter.
{
"input": {
"exerciseCount": 3,
"minimumPrefix": 48,
"maximumPrefix": 96
},
"randomDraw": 0.25,
"output": {
"result": {
"exercises": [
{
"address": "4000:4000:4000:4000:4000:4000:4000:4000",
"prefixLength": 60,
"answer": {
"expandedAddress": "4000:4000:4000:4000:4000:4000:4000:4000",
"firstHost": "4000:4000:4000:4000:0000:0000:0000:0000",
"hostBitCount": 68,
"hostCountText": "295147905179352825856",
"lastHost": "4000:4000:4000:400f:ffff:ffff:ffff:ffff",
"networkAddress": "4000:4000:4000:4000:0000:0000:0000:0000",
"prefixLength": 60
}
},
{
"address": "4000:4000:4000:4000:4000:4000:4000:4000",
"prefixLength": 60,
"answer": {
"expandedAddress": "4000:4000:4000:4000:4000:4000:4000:4000",
"firstHost": "4000:4000:4000:4000:0000:0000:0000:0000",
"hostBitCount": 68,
"hostCountText": "295147905179352825856",
"lastHost": "4000:4000:4000:400f:ffff:ffff:ffff:ffff",
"networkAddress": "4000:4000:4000:4000:0000:0000:0000:0000",
"prefixLength": 60
}
},
{
"address": "4000:4000:4000:4000:4000:4000:4000:4000",
"prefixLength": 60,
"answer": {
"expandedAddress": "4000:4000:4000:4000:4000:4000:4000:4000",
"firstHost": "4000:4000:4000:4000:0000:0000:0000:0000",
"hostBitCount": 68,
"hostCountText": "295147905179352825856",
"lastHost": "4000:4000:4000:400f:ffff:ffff:ffff:ffff",
"networkAddress": "4000:4000:4000:4000:0000:0000:0000:0000",
"prefixLength": 60
}
}
]
}
}
} Prefix zero spans all 2^128 addresses; prefix 128 spans one. Equal prefix bounds fix the mask but still consume the prefix draw. Reversed bounds, counts above 256, and invalid draws 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.
Generated addresses can fall in reserved or special-purpose spaces; there is no routability, interface-assignment, DNS, or reachability check. Questions can repeat, and answer keys are returned openly.
Alternative or Complementary methods
Calculate a chosen subnet directly with the deterministic tool. An address-set generator samples within a supplied prefix instead of generating unrelated subnet questions.
References
-
RFC 4291: IP Version 6 Addressing Architecture — IETF, RFC Editor
Similar or alternative tools
- IPv6 Subnet Calculator
Calculate the range and exact address count for a supplied IPv6 prefix.
- Random IPv6 Address Set Generator
Generate unique addresses within one supplied prefix.