ExampleDifficulty: Intermediate2 min

Subnet Example: Are 10.0.1.20 and 10.0.2.20 on the Same Network?

The answer depends on the prefix, and the same pair is one network under /16 and two under /24.

Whether two addresses share a network depends entirely on the prefix, and one pair of addresses shows it: 10.0.1.20 and 10.0.2.20 are on the same network under /16 and on different networks under /24. The method is to keep only the network bits of each address, set the host bits to zero, and compare what is left.

The question matters in practice because a machine decides from it whether to deliver a packet directly on its own link, with ARP, or to hand it to its router. Get it wrong and a packet waits for an ARP reply that never comes.

The same pair of addresses under two prefixes

Under /16same network

The network part is the first two bytes. 10.0.1.20 becomes 10.0.0.0, and 10.0.2.20 becomes 10.0.0.0. The network parts match, so the two machines reach each other directly, and the block runs from 10.0.0.0 to 10.0.255.255.

Under /24different networks

The network part is the first three bytes. 10.0.1.20 becomes 10.0.1.0, and 10.0.2.20 becomes 10.0.2.0. The network parts differ, so a packet between them must go through a router.

Three things are worth noticing.

The addresses never changed. Only the prefix did. Asking whether two addresses are on the same network without knowing the prefix has no answer.

Both machines need the same prefix. If one machine is set up with /16 and the other with /24, the first thinks the second is local and tries ARP, while the second sends its replies to the router. Traffic works in one direction only, which is among the most confusing faults a small network can have.

The boundary does not have to fall on a dot. Under /23 the network part ends one bit into the third byte, so 10.0.0.0/23 runs from 10.0.0.0 to 10.0.1.255. There, 10.0.1.20 and 10.0.0.200 share a network even though their third numbers differ, and 10.0.2.20 does not.