What is the probability of getting an IPv4 address with all even-numbered octets when randomly generating an address?

Instruction: Generate each of the four IPv4 octets independently and uniformly from 0 through 255, without excluding any address ranges. Calculate the probability all four octets are even and explain why filtering the addresses could change it.

Context: This question assesses the candidate's understanding of networking concepts and probability.

Updated

Official answer

Each octet has 256 possible values,0 through 255. Exactly 128 are even, including 0. Under independent uniform generation of all four octets:

P(all even) = (128/256)^4 = 1/16 = 0.0625, or 6.25%.

Equivalently,128⁴ of the 256⁴ possible 32-bit strings meet the condition. The result depends on the generator: sampling only public, assigned or otherwise permitted addresses can change both the sample space and the distribution. Do not assume the same fraction without checking the filter.

Follow-up: In this unfiltered model, the chance of exactly three even octets is C(4,3)(1/2)^3(1/2) = 1/4.

Assessment: State uniformity and independence, count zero correctly and distinguish bit-pattern generation from address-allocation rules.

Related Questions