NAT and port translation
What NAT changes
Network address translation (NAT) rewrites address information as packets cross a translator. In ordinary IPv4-to-IPv4 NAT (NAT44), source NAT changes a source address; destination NAT changes a destination address. Port address translation (PAT, also called NAPT) can change TCP or UDP ports as well. This allows multiple internal endpoints to share an outside IPv4 address. It conserves addresses, but it does not encrypt data or authenticate users.
Follow two simultaneous flows
Imagine two clients using the same TCP source port to reach the same server. The translator chooses distinct outside ports in this simplified mapping table. All addresses are fictional; the outside segment uses documentation addresses and is not the public Internet. Read each line as protocol, source endpoint, destination endpoint.
TCP 10.0.0.10:51000 -> 198.51.100.20:443TCP 192.0.2.9:40001 -> 198.51.100.20:443TCP 10.0.0.11:51000 -> 198.51.100.20:443TCP 192.0.2.9:40002 -> 198.51.100.20:443Reverse the mapping
A reply from the server to 192.0.2.9:40002 matches the second mapping; the translator restores destination 10.0.0.11:51000. The reply to port 40001 belongs to the first client. The transport protocol is part of the lookup. The server sees the translated address, not necessarily the original one. IP and transport checksums are adjusted as required. Real devices differ in how they choose ports, reuse mappings, filter remote endpoints and expire state. The example assumes active entries and an allowed reply from the named server.
TCP 198.51.100.20:443 -> 192.0.2.9:40002TCP 198.51.100.20:443 -> 10.0.0.11:51000Static mappings, dynamic state and limits
A static mapping is provisioned in advance; a dynamic mapping is allocated as traffic requires and may expire. Basic NAT maps addresses without relying on port sharing. A destination translation can map a service endpoint to an internal server; this alone does not grant access. Connection tracking records flow information, but a mapping is not proof of a healthy TCP session. Finite port pools and state tables can run out, and applications that carry IP addresses in their payloads may need special handling. Do not assume every translated address offers exactly 65,536 usable simultaneous connections.
Practice reading the table
Predict the restored destination of a TCP reply to port 40001. Would the same table establish a mapping for UDP port 40001? Answer: 10.0.0.10:51000; no, a TCP entry does not establish a UDP entry. Next: separate translation from firewall policy. Reference: RFC 3022 and RFC 4787 (UDP behavior).
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
NAT and port translation — knowledge check
Apply concepts to fictional translation and migration scenarios.
Two TCP clients share one outside address. What distinguishes their mappings in the worked example?
A TCP reply from the example server targets 192.0.2.9:40002. Which destination is restored?
Which field does destination NAT change?
A TCP mapping exists for port 40001. What can be inferred about UDP port 40001?
Why can a translator reject new flows even with a working route?