All guides
Term

NAT

A networking method that maps multiple private IP addresses to a single public IP address by modifying packet header information.

NAT (Network Address Translation) is a networking method that maps multiple private IP addresses to a single public IP address by modifying IP packet header information while traffic is in transit. It allows devices on a private local area network (LAN) or cloud virtual private cloud (VPC) to share one public IPv4 address for outbound internet access, conserving the limited global IPv4 address space and concealing internal network layouts from external networks.

How it works

When an internal server or client initiates an outbound connection, the NAT-enabled router or gateway intercepts the packet, replaces the private source IP address with its own public IP address, and assigns a unique source port to track the session. This mapping is stored in a state table. When the remote server replies, the gateway checks its translation table to match the destination port back to the original private IP and port, rewrites the header, and forwards the packet internally.

Common NAT implementations include:

  • Static NAT: Maps one private IP address to one dedicated public IP address on a permanent one-to-one basis, typically used to expose an internal server directly to external traffic.
  • Dynamic NAT: Maps private IP addresses to a pool of available public IP addresses on a first-come, first-served basis.
  • PAT (Port Address Translation / Overloading): Maps many private IP addresses to a single public IP address by differentiating sessions using unique TCP or UDP source port numbers.

If you are new to how server infrastructure exposes applications online, see What is web hosting and how it works: a simple explanation for an overview of public networking basics.

Example

On a Linux gateway or host acting as a router for private containers or virtual machines, outbound masquerading (a form of PAT) is configured using iptables. The following rule translates traffic leaving the 10.0.10.0/24 private subnet through the public eth0 interface:

iptables -t nat -A POSTROUTING -s 10.0.10.0/24 -o eth0 -j MASQUERADE

When a private node at 10.0.10.15 queries an external repository, the kernel rewrites the source IP to the address assigned to eth0 and tracks the return port until the connection closes.

What matters when choosing a server or hosting

Different hosting architectures handle NAT differently, affecting both network design and operational costs:

  • Dedicated public IPs vs. NAT instances: Standard VPS plans usually assign a public IPv4 address directly to the server interface, avoiding NAT overhead. Private cloud networks place backend databases and worker nodes behind a NAT gateway so they can download updates without being reachable from the public internet.
  • Managed NAT gateways vs. self-hosted: Cloud providers offer managed NAT gateways that scale automatically, whereas self-managing a Linux NAT instance reduces recurring infrastructure fees—a factor worth weighing when comparing providers in Best DigitalOcean Alternative: Price and Performance Data.
  • Connection tracking limits: High-concurrency workloads (such as web scrapers or API proxies) can exhaust available ephemeral ports on a single public IP, requiring multiple public IPs in the NAT pool.

Common mistakes

  • Treating NAT as a complete firewall: While NAT blocks unsolicited inbound connections by default, it does not inspect packet payloads or filter outbound malware traffic. Always pair NAT with explicit stateful firewall rules.
  • Exhausting the conntrack table: Under heavy traffic spikes, Linux NAT gateways can drop packets if the kernel connection tracking table fills up before stale TCP sessions time out.
  • Forgetting port forwarding for inbound services: Hosting a web server or SSH endpoint behind NAT requires explicit destination NAT (DNAT) port-forwarding rules; otherwise, external clients cannot initiate connections.

FAQ

Does IPv6 require NAT?

No. IPv6 provides a vastly larger address space, allowing every server, container, or device to receive a globally routable IP address without address translation.

What is the difference between SNAT and DNAT?

Source NAT (SNAT) rewrites the sender's IP address on outbound packets so private hosts can reach the internet. Destination NAT (DNAT) rewrites the target IP address and port on inbound packets to route external requests to an internal server.

Does NAT impact network performance?

For standard web traffic, the latency added by header rewriting is negligible. However, very high packet rates or large backup transfers—such as those discussed in Veeam Alternatives for Linux: Real Data & Practical Choices—require sufficient CPU and memory on the NAT gateway to maintain state tables without bottlenecks.

All glossary terms

Glossary

Related terms

Full glossary

New guides every week.

A digest of the best pieces on servers, VPN and self-hosted software. No ads, no spam.

1 email a weekOne-click unsubscribeRU · EN
Only slipjar.app articles, nothing else.