skip to content

Why can a worm sweep a local /24 but not generate random addresses on an IPv6 /64?

level: middleimportance: nice to knowfreq 38%

answer

  1. cost is attempts per live host found
  2. the device knows its own prefix
  3. already-resolved neighbours are confirmed live
  4. 2 to the 64 against a few hundred hosts
  5. read the neighbour cache, do not guess

basics

~20 s

Density. A /24 holds 254 usable addresses and a busy segment fills a good share of them, so sweeping all of them is trivial. A /64 holds about 18 quintillion addresses for perhaps a few hundred devices, so a random draw effectively never lands on one.

solid answer

~50 s

Next-host selection is a search problem, and its cost is set by how densely the range is populated. A /24 is 254 usable addresses; an infected device already knows the prefix from its own interface configuration, so trying every one of them is a few hundred attempts and finds essentially every neighbour. Random 32-bit generation was historically how code reached beyond its own segment, and it works only because the IPv4 space is small enough to hit something. A /64 is 2 to the power 64 addresses. With a few hundred devices in it, the chance a random draw hits a live one is around one in 10 to the power 17 - the search never terminates. So on IPv6 a spreader must stop generating and start reading: the device's own neighbour cache, the prefix advertised by the router, link-local all-nodes multicast, names it can resolve, or addresses left in configuration. That does not make an IPv6 segment safe; it makes randomness worthless and locally-known addresses decisive.

code

text · 13 lines
text
interface eth0
  inet   10.42.7.34/24          -> 254 usable neighbour addresses
  inet6  2001:db8:7::9c1f/64    -> 2^64 addresses in the prefix

ARP cache (IPv4 neighbours already resolved)
  10.42.7.1    00:1b:21:aa:bb:01
  10.42.7.19   00:80:77:3c:12:9e
  10.42.7.52   00:0f:7c:44:aa:31
  ...

IPv6 neighbour cache
  fe80::21b:21ff:feaa:bb01   REACHABLE
  ...

go deeper

for a junior

Know that a /24 holds 254 usable addresses and can be swept exhaustively, while an IPv6 /64 holds 2 to the power 64, so guessing addresses inside it is not a workable way to find hosts.

for a middle

Explain selection as attempts spent per live host found, do the density comparison, and name the local-knowledge sources - neighbour cache, advertised prefix, all-nodes multicast - that replace generation on IPv6.

for a senior

Refuse the comfortable conclusion: show that a segment-local spreader loses nothing on IPv6 because the hosts it wants are exactly the ones the infected device can already enumerate.

for a principal

Be ready to say what address-family choice actually buys - it removes the untargeted internet-wide sweep from the threat picture and leaves link-local propagation entirely intact - so nobody claims it as a spreading control.

## Selection is a search problem Code cannot attack an address it never produces. Every self-spreading program therefore carries a **next-host selection** strategy, and the strategy's quality is measured in one currency: attempts spent per live host found. Two strategies dominate, and they differ by many orders of magnitude depending on the address family. ## Sweeping the local subnet An infected device knows its own interface configuration: address and prefix length. On a flat office or branch segment that is typically a /24 - 254 usable addresses. Sweeping every one of them costs a few hundred attempts and finds essentially all the live neighbours, because a real segment packs printers, badge controllers, cameras and terminals into a range sized for exactly that. The device also holds a **free list of confirmed-live neighbours**: entries it has already resolved while doing ordinary work. Those are better than swept addresses, because each one is known to exist and to be answering. ```text infected shop-floor terminal, interface eth0 inet 10.42.7.34/24 -> 254 usable neighbour addresses inet6 2001:db8:7::9c1f/64 -> 2^64 addresses in the prefix ARP cache (IPv4 neighbours already resolved) 10.42.7.1 00:1b:21:aa:bb:01 10.42.7.19 00:80:77:3c:12:9e 10.42.7.52 00:0f:7c:44:aa:31 IPv6 neighbour cache fe80::21b:21ff:feaa:bb01 REACHABLE ... ``` That is a hot list of known-live hosts plus a trivially enumerable range, handed over by the device itself. ## Generating random addresses To reach beyond the segment, the historical technique is to generate 32-bit addresses at random and try them. IPv4 is small enough that this works despite most draws hitting space that is unallocated, unrouted or filtered: the code just makes attempts fast and accepts a low hit rate. Implementations usually bias the draw - a share of attempts inside the local /16 or /24, the rest global - precisely because the local range pays back so much better per attempt. ## Why the same idea collapses on IPv6 A standard IPv6 interface subnet is a **/64**: 2 to the power 64 addresses, about 18 quintillion. Put 300 devices in it and the probability that one random draw lands on a live address is roughly 300 divided by 1.8 times 10 to the power 19 - about one in 10 to the power 17. At a million attempts per second you would expect to wait longer than the age of the universe for a single hit. Random generation is not slow here; it is useless. Addresses are also not uniformly placed within the /64, which cuts both ways. Interface identifiers derived from a MAC address (the EUI-64 form, recognisable by the `ff:fe` in the middle - note how `00:1b:21:aa:bb:01` above becomes `fe80::21b:21ff:feaa:bb01`) concentrate the search onto vendor prefixes, and manually numbered hosts cluster at low values like `::1`, `::2`, `::10`. Privacy addressing scatters them back across the whole range. ## What replaces generation On an IPv6 segment a spreader shifts from guessing to **reading what the device already knows**: - the neighbour cache, which lists neighbours confirmed live, - the prefix learned from router advertisements, which at least bounds the search, - link-local all-nodes multicast, `ff02::1`, which every node on the link is required to join, so a single message reaches all of them, - names it can resolve, and addresses sitting in configuration files, inventories or peer lists on the host. ## The conclusion to state out loud The right takeaway is **not** "IPv6 stops worms". It is that address-space density decides which selection strategy is viable, and on a /64 the viable strategies are all local-knowledge strategies. A segment-local spreader loses nothing - the neighbour cache and multicast reach exactly the flat segment it wanted - while the internet-wide random scan that IPv4 permitted has no IPv6 equivalent. If a candidate answers this with "IPv6 is too big to scan, so it is safe", push them on multicast and the neighbour cache and watch the claim fall over.

  • Does an IPv6-addressed segment therefore resist self-spread?
    No. It defeats random generation, not propagation. An infected device on the link still has its neighbour cache, the advertised prefix, resolvable names, and link-local all-nodes multicast at ff02::1, which every node on the link joins. A segment-local spreader loses nothing, because the hosts it wanted were the ones it can already enumerate.
  • Why do random-scanning worms bias part of their draws toward the local range?
    Because return per attempt is far higher there. Addresses near the infected host are more likely to be allocated, live, reachable without traversing a filter, and running similar software, since segments are provisioned in batches. A purely uniform 32-bit draw spends most attempts on unallocated or unrouted space, so implementations split the budget between local and global draws.
  • How does interface-identifier structure affect the searchable space inside a /64?
    Sharply, in both directions. Identifiers derived from a MAC address concentrate hosts onto a vendor's range and are recognisable by the ff:fe pattern in the middle, and manually numbered hosts cluster at low values like ::1 or ::2. Privacy addressing, which generates and rotates random identifiers, undoes that concentration and pushes the search back toward hopeless.

A /24 is a street with 254 doors, so knocking on all of them is an afternoon. A /64 is a street with more doors than grains of sand on Earth and about three hundred of them occupied - you stop knocking and read the residents' list instead.

saying these in an interview costs you the question

  • Says IPv6 is too large to scan, therefore it is safe
  • Treats a /64 as merely a bigger version of a /24
  • Forgets the infected device already holds a live neighbour list
  • Overlooks link-local all-nodes multicast as an enumeration route
  • Assumes random generation was ever efficient, rather than merely viable

context