Private addresses such as 192.168.1.10 are valid only inside their own network and are not routed on the internet. At the boundary between the network and the internet, a translator replaces them with a single public address, so packets leaving for the outside carry a shared source address and replies return to whoever asked.
How it works
When an internal host opens a connection, the NAT device remembers the pair “host address and port” and substitutes its own public address and a free port. The translation entry is created by the outgoing connection, so nobody outside can connect first to a host behind NAT. For a server inside the network, you configure port forwarding, a permanent rule such as 203.0.113.7:443 → 192.168.1.20:443.
| Stage | Source | Destination |
|---|---|---|
| request before NAT | 192.168.1.10:51000 | 203.0.113.80:443 |
| request after NAT | 198.51.100.7:40001 | 203.0.113.80:443 |
| reply before NAT | 203.0.113.80:443 | 198.51.100.7:40001 |
| reply after NAT | 203.0.113.80:443 | 192.168.1.10:51000 |
Types
- static NAT: a permanent one-to-one mapping between a private and a public address, for example for a server that is reached from outside;
- dynamic NAT: private addresses take turns using addresses from a public pool;
- NAPT (PAT): both the address and the port are rewritten, so thousands of connections can share one public address; this variant is what home routers use, and
masqueradeon Linux is also called masquerading; - CGNAT: carrier-grade NAT, in which many subscribers share a public IPv4 address, which is how providers cope with exhausted address space;
- Twice NAT: the translator rewrites both the source and destination addresses, used when the address ranges of two networks overlap.
What it affects
Translation entries live for minutes (under RFC 4787, a UDP entry timer must not expire in less than two minutes), and a connection that sits idle for longer is dropped. Inbound connections are impossible without port forwarding, so an IPv4 address behind NAT is not treated as a permanent identifier. The behaviour of a translator for UDP and TCP is described by RFC 4787 and RFC 5382: for example, a single external “address and port” pair is kept for all destinations (Endpoint-Independent Mapping), which video calls, games and STUN depend on. IPv6 is regarded as the full replacement for NAT: every host gets a public address, and translation is no longer needed.
Sources
the term is written from these pages- RFC 3022 — Traditional IP Network Address Translator (Traditional NAT)rfc-editor.org/rfc/rfc3022(opens in a new tab)
- RFC 2663 — IP Network Address Translator (NAT) Terminology and Considerationsrfc-editor.org/rfc/rfc2663(opens in a new tab)
- RFC 6888 — Common Requirements for Carrier-Grade NATs (CGNs)rfc-editor.org/rfc/rfc6888(opens in a new tab)
Verified 9 Nov