What is NAT?
Network Address Translation rewrites the address and port fields of packets as they cross a router, letting many private hosts share one public IP. The router keeps a translation table, mapping each outbound flow to a free public port and reversing the rewrite on replies. Home routers do this for a household; carriers do it for whole regions.
The common form is NAPT, which translates ports as well as addresses. When a host on 192.168.1.0/24 opens a connection, the router swaps the private source address for its public one and the source port for a free port of its own, then records the mapping in a state table keyed on addresses, ports and protocol. Replies are matched against that table and rewritten back. Nothing outside learns the internal address, which is a side effect of the mechanism rather than its purpose.
Those table entries expire. A mapping for an established TCP connection is normally held through a long idle period, while UDP mappings are dropped after seconds to a few minutes, since there is no connection state for the router to watch. A long-lived session that goes quiet loses its mapping, and the next packet reaches a translator that no longer knows where to send it. Keepalives exist for this reason, and tuning their interval below the shortest timeout on the path is what makes idle sessions survive.
Translators do not all behave alike. Some reuse a single external port for a given internal socket no matter where traffic is headed, which lets an outside peer send to that port; others allocate a fresh port per destination, which makes unsolicited inbound impossible. WebRTC and VoIP work around this with STUN to discover the external mapping, TURN to relay when discovery fails, and ICE to pick among candidates. That discovery step is also how a browser can disclose addresses a proxy was supposed to hide.
If you host a proxy yourself, NAT decides whether anyone can reach it. A listener on a private address needs a forwarded port on the router and an internal address that DHCP will not move - or a backconnect design, where the proxy dials out to a gateway and clients connect to the gateway instead. Providers running mobile devices behind carrier translation have no choice but the second approach, since they cannot forward a port they do not control.
Where you meet it
NAT explains a class of problems that look like proxy faults. A SOCKS5 UDP session dies after a quiet minute because the mapping expired, and a self-hosted proxy that answers fine on the LAN times out from outside. A WebRTC test prints a local 192.168 address beside the proxy's public one. In each case the translator is behaving normally, so check the mapping and its timeout before rewriting client code.
Common questions
Is NAT the same as a firewall?
No. A translator discards unsolicited inbound packets because it holds no mapping for them, which resembles filtering, but it applies no policy and inspects nothing your hosts initiate. Run a real firewall alongside it, since plenty of attacks arrive over connections opened from inside the network.
What is the difference between NAT and CGNAT?
Scale and ownership. NAT usually runs in your own router, translating a handful of devices onto the single public address your ISP assigned. CGNAT runs inside the carrier network and places many separate customers behind one address, so you control neither the outermost translation nor any port forwarding through it.
Why does NAT break peer-to-peer connections?
Neither side can address the other directly, because both hold private addresses and only outbound flows create mappings. Applications work around it by discovering their external mapping with STUN and punching a hole with simultaneous outbound packets. When the translator assigns a different port per destination, that fails and the traffic has to go through a TURN relay.
Related terms
Real 4G/5G mobile and residential IPs
PROXIES.SX runs carrier IPs in 100+ countries with HTTP and SOCKS5 on every endpoint. $4/GB down to $2.40/GB at volume, free endpoints and rotation, and your GB never expire.