what is a NAT

Thirdpen

Network Address Translation (NAT)

How your home router allows multiple devices to share a single public internet address.


The Problem: Private vs. Public Addresses

Every device on the internet needs a unique IP address to communicate, much like a house needs a unique mailing address. However, we ran out of IPv4 addresses years ago.

NAT (Network Address Translation) allows a whole network of devices (your phone, laptop, smart fridge) to have their own "private" internal addresses, while sharing just one "public" external address provided by your ISP.

The NAT Gateway Visualization

Think of the router as a mailroom for a large apartment building. The apartments (your devices) have private numbers (192.168.x.x). The building has one public street address.

The router takes outgoing data, swaps the Private IP for the Public IP, and remembers who sent it so it can route the reply back.


The "Translation Table" (PAT)

You might wonder: If 5 devices all send data out using the same public IP, how does the router know who gets the reply?

The answer is Port Address Translation (PAT), the most common form of NAT used in homes.

The router assigns a unique port number to every outgoing connection. It writes this into a NAT Table. When a reply comes back to that specific port, the router checks the table to see which private IP ordered that data.

Interactive NAT Table

Generate traffic from different devices and watch how the router builds its translation table to keep track of connections.


Packet Header Modification

What actually happens to the data packet? NAT is essentially digital surgery. The router opens the IP packet header, rewrites the source address, and recalculates the checksum (a digital seal to ensure data integrity).

Before & After NAT

Use the slider to perform the NAT operation on a data packet leaving your network.


Types of NAT

While Port Address Translation (PAT) is the most common, there are other configurations used in large businesses or data centers.

  • Static NAT (1-to-1): One private IP is permanently mapped to one public IP. Useful for web servers inside a private network that need to be accessible from outside.
  • Dynamic NAT (Pool): A group of computers shares a small pool of public IPs. First come, first served.
  • PAT (Many-to-1): Everyone shares one IP, differentiated by ports. (What we use at home).

NAT Logic Diagram

NAT Types Diagram...

nothing is showing

Thirdpen

It looks like I forgot to start the animation loop in the code! That's why the canvas is sitting there blank.

Here is the corrected version of the NAT Types Diagram. I've added the missing start command and fixed a small issue where text alignment settings were getting stuck between animation frames.

NAT Logic Diagram

Sign in to ask follow ups

Sign In to continue