Intermediate Topic 29 of 50 Computer Networks
NAT
Translating private addresses to public ones.
How it works
Network address translation rewrites IP addresses, and usually ports, in packets as they cross a router, letting many devices with private addresses share one public address. The router keeps a translation table mapping inside address and port pairs to outside ones, so replies return to the right host; this is port address translation. Static NAT and port forwarding map specific public ports to internal servers.
Step-by-step walkthrough
- The host sends a packet from its private address.
- The router rewrites the source to its public IP and a new port.
- It records the mapping in its table.
- The reply comes back to that port.
- The router translates it back and delivers it to the host.
Where it is used
Home routers, corporate gateways and mobile carriers use NAT, which slowed IPv4 exhaustion and hides internal addressing.
Common pitfall
NAT breaks the end-to-end principle: inbound connections require forwarding, and peer-to-peer apps need techniques such as STUN, TURN and hole punching. It is not a security feature, though it blocks unsolicited inbound traffic by default. Some protocols embedding addresses need helpers, and carrier-grade NAT complicates logging. IPv6 aims to remove the need for it.
Where it fits in the course
NAT is topic 29 of 50 in Computer Networks, rated Intermediate. It follows ICMP and Ping. The next topic is Routing Algorithms.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Computer Networks quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Computer Networks quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is NAT?
Where do people use NAT?
What is the most common mistake with NAT?
What should I learn before this topic?
How can I practice it?
Is NAT hard to learn?
How long does it take to learn NAT?
Which topics are related to NAT?
What should I study after NAT?
Related topics
- ICMP and Ping (Computer Networks)
- Routing Algorithms (Computer Networks)
- ARP (Computer Networks)
- RIP and OSPF (Computer Networks)