Techโ—โ—โ—โ—โ—Difficulty 3 of 5

How can a whole household share one internet address?

In 1994 a stopgap trick was proposed to survive a few years. Your home router still uses it every second.

โ–ถ Start the story

Your home router swaps your devices' private addresses for one public address, and remembers who asked for what. This is network address translation, or NAT. An IPv4 address can address only about 4.3 billion devices, and by 1992 it was clear that would not be enough. NAT let one internet-routable address of a serve an entire private network.

Here is the trick. When a packet leaves your phone, the router replaces the private source address with its own public one and notes the connection in a table. For TCP and UDP it also changes the port numbers, so that when a reply comes back, the combination of address and port tells the router exactly which private device asked. It forwards the reply there.

A reply finds its way home
  1. Step 1: Phone sends a request

    From a private address

  2. Step 2: Router swaps the address

    Its own public address goes on the packet, and the connection is noted

  3. Step 3: Website replies

    To the router's public address

  4. Step 4: Router looks up the entry

    And forwards the reply to the right device

NAT was never meant to last. A 1994 document called NAT a short-term solution to the problems of running out of addresses and routing at scale. By 2004 it was widespread. The stopgap had quietly become part of how the internet works.

There is a catch. Communication through the router works only when the conversation starts inside the private network. A browser inside can reach outside websites, but outsiders cannot simply visit a website hosted inside. Hosts behind NAT lose and cannot take part in some internet protocols, which is why video calls and other apps need extra tricks to work.

Quiz me

0/3

  1. 1.How does a NAT router know which device a returning reply belongs to?
  2. 2.Why can a stranger on the internet not simply open a connection to a laptop behind NAT?
  3. 3.Why is NAT not commonly needed with IPv6?

Recap

The router swaps private addresses for its public one, tracks each connection by address and port, and sends replies back to the right device.

๐Ÿ’ก A trick to remember it ยท The router is a doorman with a notebook: he stamps his own address on every letter going out and checks the notebook when a reply arrives.

Surprising fact ยท A 1994 document called NAT a short-term solution, yet it became widespread by 2004.

Sources (1)

No source, no claim. Every fact in this lesson (16 claims) cites at least one of these.

  1. [1]Network address translation ยท Wikipedia
More lessons in ๐Ÿ’ป Tech (3) See all tech lessons โ†’

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson โ†—