Vol. I · No. 46The protocol sectionSat, 10 Oct 2026
Layer 3 · The Internet Layer · many hosts, one address

NAT

Network Address Translation

NAT is the reason your whole house shares one address. At the edge of a network it rewrites the source address and port of every outgoing packet, remembers the mapping it made, and reverses it on the way back — an ingenious workaround for IPv4 running out of addresses.

NAT rewrites addresses at the border so many private hosts share one public IP — and the mapping table is what makes replies find their way home.

Operates at
Layer 3 / 4
address and port
Common form
PAT
many → one, by port
Keeps
State
a translation table
On IPv6
Not needed
addresses aren’t scarce

How it works

One public address, shared by rewriting ports
The translation table, entry by entry
Inside (private)
Outside (public)
10.0.0.9 : 51000
203.0.113.7 : 40001
10.0.0.12 : 52000
203.0.113.7 : 40002
10.0.0.9 : 51001
203.0.113.7 : 40003

Two hosts may pick the same source port, so NAT gives each flow its own public port. A reply to 40002 can therefore only belong to one conversation — and an unsolicited packet matches nothing and is dropped.

The main points

What NAT does, step by step

1
Packet leaves

A host sends out a packet with a private source address that is not routable on the internet.

2
Rewrite and record

The gateway swaps in its public address and a free port, and stores the pair in its table.

3
Reply comes back

The return packet is addressed to that public port; the gateway looks the port up in the table.

4
Restore and deliver

It writes the original private address and port back in and forwards the packet to the right host.

Kinds of translation
Static NAT — one private ↔ one public
Dynamic NAT — a pool, first come first served
PAT / overload — many behind one, by port
Port forwarding — a hole punched inward
Hairpin NAT — inside reaching its own public IP
CGNAT — the ISP NATs you too

In cybersecurity

NAT hides internal hosts as a side effect — genuinely useful — but it is an addressing trick, not a security policy.

Not a firewall

It drops unsolicited inbound because nothing matches, not because a rule said to. Add real filtering.

Port forwarding

Every forwarded port is a deliberate route straight to an internal host — audit them.

UPnP opens holes

Software on the LAN can ask the router to forward ports with no one approving it.

State exhaustion

The translation table is finite; a flood of flows fills it and new connections fail.

Attribution is hard

Behind CGNAT thousands share one address, so logs need the port and the timestamp too.

Breaks end-to-end

Protocols that carry addresses inside the payload — SIP, FTP — need helpers or they fail.

Rides in the stack

IPNATTCP / UDP

NAT isn’t a protocol on the wire at all — it is a rewrite performed on packets as they cross the border.

Works with

IPv4IPv6

See it on Linux

nftiptables

Private ranges & state

Private IPv4
10/8large
172.16/12medium
192.168/16home
100.64/10CGNAT
What it tracks
Src IP:portinside
Pub IP:portoutside
ProtocolTCP/UDP
Timeoutidle age-out