Networkingnetwork address translationpatport address translationnat gateway

NAT (network address translation)

Definition

Network address translation rewrites the IP addresses (and usually ports) in packets as they cross a router, keeping a translation table so that return traffic reaches the right internal host.

In practice

NAT is why a whole household or a private cloud subnet can reach the internet through one public IPv4 address. Outgoing packets get the public address and a unique port; the router records the mapping and translates replies back. Cloud NAT gateways do the same for private instances.

Because mappings are created only by outgoing traffic, unsolicited inbound connections have nowhere to go, which breaks peer-to-peer traffic and forces tricks such as STUN, TURN relays or port forwarding. Translation tables also hold state: idle mappings time out, long-lived connections need keepalives, and a busy NAT can run out of ports for one destination.

Example

Laptop 192.168.1.23:51544 connects out; the router maps it to 198.51.100.4:40001 and rewrites the reply from the server back to 192.168.1.23:51544.