Skip to main content
CSNetworkingDiagramBeginner

NAT (Network Address Translation)

KO: NAT (네트워크 주소 변환)·EN: NAT (Network Address Translation)·JA: NAT(ネットワークアドレス変換)·Network Address Translation

A router mechanism rewriting private IP addresses and ports into shared public IP addresses to conserve IPv4 space and shield internal hosts

Table of Contents

Structure Diagram

NAT / PAT Private IP ↔ Public IP & Port TranslationTap a node
map :40001map :40002Public IP PC 1 (192…Phone (19…NAT Route…Internet …
ROOTPC 1 (192.168.0.10:5001)
1 link
Quick Answer

What is NAT (Network Address Translation)?

A router mechanism rewriting private IP addresses and ports into shared public IP addresses to conserve IPv4 space and shield internal hosts. It is a core concept in Networking within CS.

Core Principles

NAT (Network Address Translation) rewrites private source/destination IPs at a network boundary so private subnets (10.0.0.0/8, 192.168.0.0/16) can communicate over the public internet using shared IPv4 addresses.

  • PAT / NAPT: Maps thousands of internal hosts onto a single public IP by assigning unique ephemeral ports in a stateful translation table.
  • SNAT vs DNAT: SNAT translates outbound source addresses; DNAT forwards inbound traffic to internal servers (port forwarding / load balancing).

Practical Takeaways

  • Watch for SNAT port exhaustion: Each public IP has ~64K ephemeral ports per destination tuple—high-churn outbound traffic requires connection pooling or multiple egress IPs.
  • NAT Traversal for P2P/WebRTC: Direct peer connections behind NAT rely on STUN, ICE / UDP hole punching, and TURN relays.
  • Avoid cloud NAT data charges: Route S3/DynamoDB traffic through free VPC Gateway Endpoints instead of paying per-GB NAT Gateway fees.

Notable Examples

  • Home Wi-Fi Routers: Sharing one ISP IPv4 address across every household device.
  • AWS NAT Gateway: Giving private-subnet servers outbound internet access without inbound exposure.
  • Kubernetes Services: kube-proxy DNATing ClusterIP traffic to backend Pods.