Services

Resources

Company

/

Network address translation

NAT (network address translation)

Network address translation (NAT) is the rewriting of source or destination IP addresses, and often ports, in packets as they cross a router or gateway. Its most common use lets many hosts with private addresses, such as 10.0.0.0/8, reach the internet through one or a few public IP addresses. Replies are translated back to the right private host.

How it works

Source NAT (SNAT) rewrites the sender's address on the way out and records the mapping in a connection-tracking table. Destination NAT (DNAT) rewrites the target address on the way in, which is how port forwarding works. On Linux, iptables rules in the nat table implement both. For example, iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE lets a machine share its internet connection. Kubernetes uses similar rules to route Service traffic to pods.

Why it matters in production

Managed NAT gateways in the cloud usually charge per GB of data processed. A workload that pulls 100 TB per month from the internet can make NAT one of the largest line items on the bill. NAT also hides the original client address and can exhaust source ports under heavy connection churn.

See also

On the One2N blog

References

  1. Origin of the term

  2. RFC 3022: Traditional IP network address translator

  3. The netfilter.org project

Network diagram of NAT: three private hosts, A, B and C, in a 10.0.0.0/8 network send traffic to a NAT gateway, which reaches the internet from 1 public IP. Its connection table maps A, B and C to the public IP on ports a, b and c, so replies go back to the right host. In red above the gateway: cloud NAT is billed per GB processed, and 100 TB a month makes it a top bill item.

Putting this into practice?

Talk to One2N about our platform engineering services

Talk to One2N about our platform engineering services