Course contentsShow
← Computer Science
Lesson 1466 of 2,87234. Internet Protocol SuiteFree lesson

Network Address Translation (NAT)

How NAT allows private networks to share public IP addresses by translating addresses at gateway routers.

Network Address Translation (NAT)

You'll learn: How NAT enables an entire private network to share a single public IP address by rewriting packet addresses at the gateway.

The Problem NAT Solves

Remember when we learned about private IP ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16)? These addresses are perfect for internal networks, but they're not routable on the Internet. So how does your laptop with IP 192.168.1.100 communicate with websites?

How NAT Works

Network Address Translation sits at your gateway router (the boundary between your private network and the Internet) and translates addresses in both directions:

Outbound Translation

When a device on your private network sends a packet to the Internet:

  1. Original packet: Source = 192.168.1.100:5000, Destination = 93.184.216.34:80
  2. NAT router rewrites it: Source = 203.0.113.5:12345 (router's public IP + unique port), Destination = unchanged
  3. The router maintains a NAT translation table mapping 192.168.1.100:5000 ↔ 203.0.113.5:12345

Inbound Translation

When the response comes back:

  1. Incoming packet: Source = 93.184.216.34:80, Destination = 203.0.113.5:12345
  2. NAT router looks up the mapping and rewrites: Destination = 192.168.1.100:5000
  3. Packet delivered to the correct internal device

The Analogy

Think of NAT like a corporate mail room: employees (private IPs) write letters but use the company's address (public IP) as the return address. The mail room adds a department code (port number) so replies reach the right person.

Key Takeaway: NAT allows many devices with private IP addresses to share a single public IP address by translating source addresses and ports at the gateway router, solving IPv4 address scarcity while maintaining network functionality.