01 / 22

Network Address
Translation (NAT)

Understand how NAT maps private IP addresses to public ones, its impact on network exposure, and why it matters for security logging.

Cyber Security

What Is NAT?

Network Address Translation (NAT) is a method used by routers to translate private (internal) IP addresses into a public (external) IP address before packets leave the local network. It was originally designed to conserve the limited pool of IPv4 addresses.

Why Does NAT Exist?

IPv4 Exhaustion
Only \(2^{32} \approx 4.3\) billion IPv4 addresses exist: far fewer than the devices on Earth. NAT lets many devices share one public IP.
Security Benefit
Internal hosts are hidden behind the router's public IP, making them harder to target directly from the internet.
Simplified Routing
ISPs only need to route traffic to one public address per customer, reducing the size of global routing tables.

Private vs Public Addresses

Private Addresses Public Addresses
Ranges (RFC 1918) 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 All other routable IPv4
Routable on Internet? No Yes
Unique Globally? No: reused in every LAN Yes: assigned by IANA/RIRs
Visible to External Servers? No: hidden by NAT Yes

How NAT Works

192.168.1.10 192.168.1.11 192.168.1.12 Private Network NAT Router Translation Table
\( \text{src IP:port} \rightarrow \text{public IP:port} \)
Internet 203.0.113.5 Public IP Many private IPs One public IP

The Translation Table

Every NAT router keeps a stateful table that tracks active connections. Each entry maps an internal source to a rewritten external source:

Internal Source External (Rewritten) Destination
192.168.1.10:52301 203.0.113.5:40001 93.184.216.34:443
192.168.1.11:48822 203.0.113.5:40002 93.184.216.34:443
192.168.1.12:61045 203.0.113.5:40003 142.250.80.46:80

Types of NAT

Static NAT
One-to-one permanent mapping. A specific private IP always maps to the same public IP. Used for servers that need to be reachable from outside.
Dynamic NAT
One-to-one temporary mapping from a pool of public IPs. The router assigns a public IP on demand, then reclaims it when the session ends.
PAT (Overload)
Many-to-one mapping using port numbers to distinguish sessions. The most common type: your home router almost certainly uses PAT.

Comparing NAT Types

Static Dynamic PAT / Overload
Mapping Ratio 1 : 1 1 : 1 (from pool) Many : 1
Port Rewriting? No No Yes
Inbound Access Allowed Limited Blocked by default
IP Conservation Low Medium High
Typical Use Public servers Enterprise egress Home / SMB routers

NAT and Exposure

NAT provides a form of "security by obscurity" for internal hosts. Because external systems only see the router's public IP, they cannot directly initiate connections to devices behind PAT without explicit configuration.

1
Reduced attack surface: Internal hosts are unreachable from the internet unless a port forwarding rule exists.
2
No direct scanning: An attacker running a port scan sees only the router's public IP and its open ports, not the internal LAN.
3
Not a firewall: NAT blocks unsolicited inbound traffic, but it does not inspect packet contents or enforce security policies like a stateful firewall does.

Port Forwarding Breaks the Shield

Attacker → port 8080 NAT Router Port Forward Rule
\( 8080 \rightarrow 192.168.1.50:80 \)
Web Server 192.168.1.50:80 Port forwarding exposes the internal host! The server is now directly reachable from the internet.

NAT and Logging Challenges

When hundreds of internal users share one public IP, external logs only record that single address. This creates serious challenges for forensic investigations and incident response.

Attribution Problem
A web server log shows 203.0.113.5 visited at 14:32. But which of the 200 users behind that NAT was responsible?
Timestamp Correlation
To identify the user, you must correlate the external log's timestamp and port with the NAT router's translation table at that exact moment.

Solving the Logging Problem

1
Log NAT translations: Configure the router to log every translation entry with timestamps, internal IP, internal port, external port, and protocol.
2
Synchronize clocks (NTP): Both the NAT device and external services must use the same time source so timestamps can be correlated accurately.
3
Centralize logs (SIEM): Send NAT logs to a Security Information and Event Management system where they can be cross-referenced with other event data.
4
Retain logs appropriately: Regulations may require NAT translation logs to be kept for months or years to support investigations.

How to Trace Through NAT

1
Obtain the external log entry: Note the public IP, destination port, and exact timestamp from the remote server's log.
2
Query the NAT translation log: Search for the matching public IP, external port, and timestamp window.
3
Identify the internal IP: The translation entry reveals which private IP and port originated the connection.
4
Cross-reference with DHCP logs: If the internal IP was dynamically assigned, check DHCP logs to identify the specific device or user.
5
Document the chain of evidence: Record every correlation step for legal or compliance purposes.

Example: Outbound Web Request

Laptop 192.168.1.10:52301 Src: 192.168.1.10 NAT (PAT)
Rewrites src \( \rightarrow \)
Src: 203.0.113.5:40001 example.com 93.184.216.34:443 The web server's log records:
\(203.0.113.5:40001 \rightarrow 93.184.216.34:443\)
Not the laptop's private IP (192.168.1.10)

Example: Carrier-Grade NAT (CGNAT)

Customer A 192.168.1.10 Home NAT 100.64.0.10 Customer B 192.168.1.10 Home NAT 100.64.0.20 ISP CGNAT Double NAT! Internet 203.0.113.1 Both customers appear as 203.0.113.1 Same private IP (192.168.1.10) in different networks! Tracing requires ISP CGNAT logs + Home NAT logs + timestamps

Common Mistakes About NAT

✕ "NAT is a firewall"
NAT blocks unsolicited inbound traffic as a side effect, but it does not inspect packets, filter by rules, or detect malicious content. A real firewall is still required.
✕ "NAT hides all activity"
Outbound traffic still reveals the public IP. Websites, CDNs, and law enforcement can still see which public IP accessed a resource and at what time.
✕ "Logging the public IP is enough"
Without the NAT translation table and synchronized timestamps, the public IP alone cannot be attributed to a specific internal user, especially with PAT or CGNAT.

Summary Table

Concept Key Takeaway
NAT Purpose Maps private IPs to public IPs to conserve IPv4 addresses
PAT (Overload) Many-to-one using unique port numbers per session
Exposure Internal hosts hidden unless port forwarding is configured
Port Forwarding Creates a direct path from internet to internal service
Logging Challenge Public IP alone is insufficient: need NAT logs + timestamps
CGNAT Double NAT at ISP level makes tracing even harder
NAT vs Firewall NAT is not a security tool: always deploy a real firewall

Question 1 of 5

What is the primary purpose of NAT?

Question 2 of 5

In PAT (Port Address Translation), how does the router distinguish between multiple internal hosts sharing the same public IP?

Question 3 of 5

A web server log shows suspicious activity from 203.0.113.5. The organization uses PAT. What additional information is needed to identify the responsible internal user?

Question 4 of 5

Why is NAT not considered a replacement for a firewall?

Question 5 of 5

What security risk does port forwarding introduce in a NAT environment?