NAT: How Replies Find the Right Device
A laptop and a phone can visit the same website through one home internet address. The replies still find the right device. The router makes that possible by rewriting some of the traffic's addressing information and keeping a record of what it changed.
That work is NAT, short for network address translation. It changes IP addresses, the addresses used to send data between devices, as traffic crosses from one network to another. This home example uses Internet Protocol version 4, or IPv4. The familiar home-router version also changes port numbers, which help distinguish the conversations handled by different programs.
Together, those changes let devices with separate local addresses share an address facing the internet. The translation happens to traffic already carrying those local addresses; NAT doesn't assign them to the devices.
- Give every phone, laptop and TV a steadier connection with Wi-Fi 6.
- Stop the buffering at busy hours, with room for many devices at once.
- Replace an aging router and get stronger coverage across more of your home.
The return address has two useful parts
Suppose the laptop sends a request to a website. The request travels in packets, small units of network data. Its source information includes the laptop's local IP address and a port number.
As the packet leaves the home network, the router substitutes an external address and port. It keeps a mapping: a record connecting that external combination with the laptop's original combination.
The phone can make its own request through the same external address. The router gives it a distinguishable mapping. In this simplified, invented example, even the same local port number causes no confusion:
| Device inside the home | Port used with the shared external address |
|---|---|
| Laptop, local port 5000 | 40001 |
| Phone, local port 5000 | 40002 |
A reply arriving for the first mapping gets its destination changed back to the laptop's local address and port. A reply for the second goes to the phone. The router can then forward each reply to the device waiting for it.
How One Public Address Serves a Whole House
The traditional NAT specification calls this address-and-port form NAPT, or Network Address Port Translation. Basic NAT translates addresses; NAPT translates addresses and ports. Everyday references to home NAT usually mean the latter.
The records also have lifetimes. They serve the exchanges that need translation, rather than keeping a permanent directory of everyone who has ever connected.
Starting outside is a different problem
An incoming reply has an existing exchange to match. A brand-new connection from outside may not.
Suppose someone wants to reach a service running on a computer at home. A packet arrives at the shared public address, but the router has no suitable mapping telling it which internal computer should receive it. The incoming path that worked for a website's reply doesn't automatically exist for this new request.
This helps explain why browsing can work while hosting a service or making a direct connection between peers needs additional arrangements. The obstacle is the kind of connection being attempted, not necessarily a generally slow or broken internet service.
A permanent mapping can make a chosen internal service reachable. A firewall rule still determines whether that incoming traffic is allowed.
- Get five gigabit ports and a fast ARM processor for the price of a basic home router.
- Practice real routing at your desk on gear that network pros also deploy.
- Tuck it beside your modem: it takes up almost no room.
What the router should let through
A firewall applies rules about permitted traffic. NAT changes addresses. A router can do both jobs, which makes them easy to confuse.
The Internet Engineering Task Force's analysis of local network protection explicitly separates translation from security. A missing mapping may keep a new incoming connection from reaching a device. Filtering rules decide which traffic is allowed. Simply changing an address doesn't inspect the contents for danger.
Nor does substituting a public address encrypt a message or make its sender anonymous. An allowed connection can still carry harmful content. Private addresses describe the local addressing arrangement; they aren't a promise that every device using one is safe.
Why the Internet Is Running Out of Addresses
There may be another translator upstream
An internet provider can also share public IPv4 addresses among subscribers using carrier-grade NAT. A home router that performs NAT can then sit behind a second translation layer at the provider.
The carrier-grade NAT requirements describe this arrangement. It means changing a home-router setting may leave another obstacle to incoming connections untouched. The provider's layer has its own mappings and behavior.
Private Addressing: Why Separate Networks Can Reuse IP Numbers

Source Ports: The Number Changes Roles When the Reply Returns

Socket Pair: The Two Ends of a Connection

QUOTE:
"Amateurs hack systems, professionals hack people."

