Network Address Translation (NAT)

Published: (May 3, 2026 at 12:51 AM EDT)
2 min read
Source: Dev.to

Source: Dev.to

Private vs. Public IP Addresses

Public IP addresses are globally unique identifiers assigned by Internet Service Providers (ISPs). Devices with public IPs can be accessed from anywhere on the Internet, enabling worldwide communication.

Private IP addresses are intended for use within local networks such as homes, offices, and schools. They are not routable on the global Internet and therefore cannot be forwarded by backbone routers. Defined by RFC 1918, common IPv4 private address ranges include:

  • 10.0.0.0 – 10.255.255.255
  • 172.16.0.0 – 172.31.255.255
  • 192.168.0.0 – 192.168.255.255

These private networks operate independently of the Internet while facilitating internal communication. By using NAT, a local network can employ private IPs while sharing a single public IP address, conserving the limited public address pool and adding a layer of security by isolating internal devices from direct exposure.

How Does It Work?

Network Address Translation is performed by a router (or similar device) that modifies the source or destination IP address in packet headers as they traverse the network. The process translates private IP addresses of devices within the local network to the router’s public IP address.

Example:
A home network contains a laptop (192.168.1.10), a smartphone, a tablet, and a smart thermostat. When the laptop requests a DNS server on the Internet, the router replaces the laptop’s private source IP with its public IP (e.g., 203.0.113.50). The router also assigns a dynamic source port (e.g., 4444). When the response returns, the router consults its NAT table, which maps 203.0.113.50:4444 back to 192.168.1.10:5555, and forwards the packet to the correct internal device.

Types of NAT

Static NAT

  • One-to-one mapping between a private IP address and a public IP address.

Dynamic NAT

  • Assigns a public IP from a pool to a private IP as needed, based on demand.

Port Address Translation (PAT) – NAT Overload

  • Multiple private IP addresses share a single public IP address.
  • Differentiates connections using unique source port numbers.
  • Most common in home and small‑office environments.

Benefits and Trade‑Offs

Benefits

  • Conserves the limited IPv4 address space.
  • Provides a basic security layer by hiding internal network structure.
  • Allows flexible internal IP addressing schemes.

Trade‑Offs

  • Hosting public services behind NAT often requires additional configuration (e.g., port forwarding).
  • Certain protocols that rely on end‑to‑end connectivity may break without special handling.
  • Increases complexity when troubleshooting connectivity issues.
0 views
Back to Blog

Related posts

Read more »

VPN vs Proxy Explained in 5 Minutes

The basic idea Both VPNs and proxies act as a middle person between you and the internet. Instead of your device talking directly to a website, your request go...