LearnViz CompSci
Home / Learn / Computer Networks / NAT

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

  1. The host sends a packet from its private address.
  2. The router rewrites the source to its public IP and a new port.
  3. It records the mapping in its table.
  4. The reply comes back to that port.
  5. 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

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Computer Networks quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is NAT?
Translating private addresses to public ones. It belongs to Computer Networks and is an intermediate-level topic.
Where do people use NAT?
Home routers, corporate gateways and mobile carriers use NAT, which slowed IPv4 exhaustion and hides internal addressing.
What is the most common mistake with NAT?
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.
What should I learn before this topic?
Start with ICMP and Ping, the topic just before it in Computer Networks.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Computer Networks quiz.
Is NAT hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn NAT?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to NAT?
ICMP and Ping, Routing Algorithms, ARP are closely connected. The full list is in the related topics section of this page.
What should I study after NAT?
Continue with Routing Algorithms, the next topic in Computer Networks.

Related topics