Packet.School
HomeLevelsSandboxFreeAbout
XP0
L5 · Advanced Topics
Level 5
6 lessons
  • 01Subnetting Basics
  • 02Subnet Calculation
  • 03What is NAT?
  • 04VPN
  • 05Terminal Commands
  • 06Final Quiz
Levels/L5 · Advanced Topics/Lesson 03
Lesson · 03

What is NAT?

NAT is the technology that translates private IP addresses into public ones. It's the secret behind ten devices in your home sharing a single public IP to reach the internet.

Duration
3min
Level
L5
Type
Lesson
Progress
3/ 6

01Why is NAT needed?

IPv4 offers only ~4.3 billion addresses; the number of connected devices is far beyond that. The workaround: everyone inside uses private IPs, and one public IP is shared at the exit.

code
Internal (private)           NAT          Internet (public)
192.168.1.10  ────┐
192.168.1.11  ────┼───→ [Router] ───→ 203.0.113.5
192.168.1.12  ────┘      (NAT)

02Private IP ranges

Reserved by RFC 1918, never routed on the internet:

ClassRangeCIDRAddresses
A10.0.0.0 – 10.255.255.255/816.7 million
B172.16.0.0 – 172.31.255.255/121 million
C192.168.0.0 – 192.168.255.255/1665,536
Try it at home
The address in your ipconfig output is almost certainly 192.168.x.x — but search "what is my ip" and you'll see something completely different. Your router performs that translation every second. That's NAT.

03NAT types

1. Static NAT (1:1)

code
Inside: 192.168.1.10 ←→ Outside: 203.0.113.10

A fixed public IP for each internal IP. Used for servers; needs many public IPs.

2. Dynamic NAT

code
Inside IPs → [NAT pool] → outside IPs

A free IP is taken from the pool; when the pool runs dry, new connections wait.

3. PAT (Port Address Translation)

code
192.168.1.10:5000 → 203.0.113.5:40001
192.168.1.11:5000 → 203.0.113.5:40002
192.168.1.12:5000 → 203.0.113.5:40003

The most common type: one public IP, thousands of connections — told apart by port number. Also called "NAT overload"; this is what home routers do.

04How PAT works

Outgoing packet

code
PC1: 192.168.1.10:3000 → google.com:443

The router records in its NAT table:
| Inside IP:Port      | Outside IP:Port   |
|---------------------|-------------------|
| 192.168.1.10:3000   | 203.0.113.5:40001 |

The outgoing packet is now:
203.0.113.5:40001 → google.com:443

Incoming reply

code
google.com:443 → 203.0.113.5:40001

Router checks the table: 40001 → 192.168.1.10:3000
Forwards inside: google.com:443 → 192.168.1.10:3000

05NAT's limitations

  1. Peer-to-peer pain — two devices behind NATs can't find each other directly
  2. Some protocols struggle — FTP, SIP and others that carry IPs in the payload
  3. Port ceiling — ~65,000 concurrent connections per public IP
  4. End-to-end connectivity breaks — the IP changes mid-path

06Port forwarding

The way to reach a server behind NAT from outside:

code
Internet → Router (203.0.113.5:80) → Web server (192.168.1.100:80)

Router rule: forward everything arriving on external port 80 to 192.168.1.100:80. This is exactly what you configure when hosting a game server at home.

07Summary

  • NAT = private IP ↔ public IP translation; the practical fix for IPv4 scarcity
  • PAT shares one IP across thousands of connections via port numbers
  • Your home router is doing PAT right now
  • The cost: broken end-to-end connectivity — one of the problems IPv6 solves
Previous
Subnet Calculation
Next
VPN
On this page
  • Why is NAT needed?
  • Private IP ranges
  • NAT types
  • How PAT works
  • NAT's limitations
  • Port forwarding
  • Summary
Packet.School

An open, interactive curriculum for computer networking.

v3.0 · MIT22 lessons live

Learn

  • Lessons
  • Sandbox
  • Levels
  • Free
  • About

Simulations

  • Packet Journey
  • DNS Lookup
  • DHCP Simulator
  • Subnet Calc
  • Network Builder
  • Terminal

Project

  • About
  • Changelog
  • GitHub
  • Contributing
  • Style guide

Newsletter

One short email when a new level ships. No tracking pixels.

© 2026 Packet.School — MIT licensedSupport with a coffeebuilt in the open