skipnothing/HTTP & Networking

IP Addresses

Run ifconfig and one line reads inet 192.168.1.42, which looks like four small numbers with dots between them. It is really one 32-bit integer, and its leading bits alone already say whether it can leave your machine at all.

  • ▸The dots in 192.168.1.42 punctuate a single 32-bit number; its leading bits alone name what kind it is.
  • ▸Two machines can both answer to 192.168.1.5 and neither is wrong, because that number never leaves its own network.
  • ▸:: may appear only once in an IPv6 address; a second one would leave it ambiguous.
01

An address is one number

192.168.1.42 looks like four small numbers a person picked. It is one number. The dots are punctuation a machine ignores: underneath, the address is a single 32-bit integer, and each dot marks where one 8-bit slice, an octet, ends and the next begins. Each octet runs 0 to 255, because eight bits count no higher.

Write the address in binary and the four groups become one unbroken row: 11000000 10101000 00000001 00101010. Set the last octet from 42 to 255 and only the final eight bits move; the other twenty-four sit still. You did not change four numbers. You changed one slice of a single integer that was always there under the dots.

ONE INTEGER, FOUR OCTETS
02

The class lives in the leading bits

Two addresses on your own machine, 127.0.0.1 and 192.168.1.5, never travel the same distance, and you can tell which is which without a lookup. The leading bits decide.

An address whose top bits fall in 10, 172.16 through 172.31, or 192.168 is a private address: real, usable, but meaningful only inside its own network. An address starting 127 is loopback, it turns around inside the host and never reaches a wire. One starting 169.254 is link-local, the address a machine hands itself when it asked for a lease and heard nothing back.

The badge that names each one is not calling a registry. It is reading the front of the number.

THE BADGE READS THE LEADING BITS
03

The slash cuts network from host

Give an address a slash and a number, 192.168.1.0/24, and you have drawn a line through its bits. The number after the slash says how many leading bits name the network; everything to the right names hosts inside it. That is CIDR notation.

A /24 fixes the first twenty-four bits and leaves eight for hosts, so it holds 2^8, or 256 addresses. Slide the cut left to /16 and sixteen host bits remain: 65,536 addresses, two hundred fifty-six times as many. Each bit you hand from network to host doubles the space, because one more bit is one more power of two. A /32 leaves no host bits at all and names exactly one address.

DRAG THE CUT, COUNT THE HOSTS
04

The same address, two networks

Put 192.168.1.5 on your laptop. Now put 192.168.1.5 on a laptop in another building, on a different network. Nothing breaks. Both are legal, and neither machine is wrong, because a private address is a local name: it means something only on the network it lives on, and it never leaves. The two addresses are identical strings that never meet.

Swap one for a public address like 8.8.8.8 and the picture changes: a public address is handed out to a single place on the internet, so the same one in two networks is a real conflict. The rule underneath is one line: a private address has no global meaning, which is exactly what makes reusing it safe.

SAME ADDRESS, TWO NETWORKS, NO CONFLICT

Keep going, sign up to unlock the rest

1 more part in this topic, plus 23+ more topics in HTTP & Networking.

Sign up, it's freeSee the full HTTP & Networking
Names & Addresses0/5
#2 Ports & Sockets