What Is Network Address Translation (NAT)? How It Works
In this article
Network Address Translation (NAT) is a method used in computer networking to modify the IP address information in packet headers while they are in transit across a routing device. In simple terms, NAT allows multiple devices on a private network (like your home Wi-Fi) to share a single public IP address when connecting to the internet. It is a core function of most home routers and enterprise firewalls, and it was developed primarily to slow the exhaustion of IPv4 addresses.
Background: Why NAT Was Created
The internet runs on IP addresses—unique numeric identifiers that let data find its destination. The original protocol, IPv4, uses 32-bit addresses, providing about 4.3 billion unique addresses. When the internet exploded in the 1990s, it became clear that 4.3 billion was not enough for every device to have its own public address. NAT was formalized in RFC 1631 (1994) as a temporary solution. It allows an entire private network to use a single public IP address, effectively multiplying the usable address space. Today, NAT is also a key security feature because it hides internal IP structures from the outside world.
How NAT Works: The Basic Process
When a device on your private network (e.g., 192.168.1.5) sends a request to a website, the router receives that packet. The router then maps the private IP and source port to its own public IP and a new port number. It records this mapping in a translation table. When the response comes back, the router looks up the table, reverses the translation, and forwards the packet to the original device. This process is often called port address translation (PAT) or NAPT (Network Address Port Translation), which is the most common form of NAT used in home routers.
Here is a concrete example:
- Your laptop (192.168.1.10:54321) sends a packet to a web server (203.0.113.5:80).
- The router changes the source to its public IP (198.51.100.1:40000) and records the mapping.
- The web server replies to 198.51.100.1:40000.
- The router sees the mapping, changes the destination back to 192.168.1.10:54321, and delivers the packet.
This works for most traffic, but it breaks certain protocols that embed IP addresses in the payload (like FTP or SIP). For those, NAT needs special helpers or ALGs (Application Layer Gateways).
Types of NAT: Static, Dynamic, and PAT
NAT is not a single mechanism; it has several variants, each with a different use case.
- Static NAT: A one-to-one mapping between a private IP and a public IP. This is used when a server inside the network must be reachable from the internet at a fixed address. Example: 192.168.1.10 always maps to 203.0.113.10.
- Dynamic NAT: Maps a private IP to a public IP from a pool of available addresses. The mapping is temporary and changes over time. It is rarely used today because it still requires multiple public IPs.
- Port Address Translation (PAT): This is what most people mean by NAT. Many private IPs share a single public IP, distinguished by different source ports. PAT is the default on virtually all home routers.
Another important distinction is source NAT (SNAT) vs. destination NAT (DNAT). SNAT changes the source address of outgoing packets (as in the example above). DNAT changes the destination address of incoming packets, which is how port forwarding works—it forwards traffic from a public port to a specific internal server.
Common Problems with NAT
NAT is not without its drawbacks. The most common issues include:
- Breaking peer-to-peer connections: Protocols like VoIP, gaming, and BitTorrent often require direct connections. NAT makes it hard for external devices to initiate communication with a device behind NAT.
- Port exhaustion: Because PAT uses source ports to differentiate sessions, a heavy network can run out of available ports (max ~65,535 per public IP). This is rare for home use but can happen in large enterprises.
- Protocol issues: Some protocols (like FTP in active mode) embed IP addresses in the data stream, causing NAT to corrupt the connection unless an ALG is present.
- Double NAT: When two routers are cascaded (e.g., ISP router + your own router), each performs NAT, which can cause issues with port forwarding and online gaming. Solutions include putting one router in bridge mode or using DMZ.
NAT vs. IPv6: The Future
NAT was a stopgap for IPv4 address exhaustion. The long-term solution is IPv6, which provides 340 undecillion addresses (2^128). With IPv6, every device can have a unique public address, eliminating the need for NAT in most cases. However, IPv6 adoption has been slow. Many networks still use IPv4 or run dual-stack (both protocols). Even with IPv6, NAT is sometimes used for privacy (to hide a device's true address) or for security, but it is not required. In IPv6, the equivalent of NAT is called NPTv6 (Network Prefix Translation), which is less common.
How to Choose NAT Settings: Port Forwarding and UPnP
For most home users, NAT works automatically. But when you need to host a game server or access a security camera remotely, you must configure port forwarding. This is a form of DNAT that tells the router to send traffic on a specific public port to a specific internal IP and port. Steps usually involve:
- Find your device's private IP (e.g., 192.168.1.10).
- Log into your router's admin page (typically at 192.168.1.1 or 192.168.0.1).
- Look for a section called "Port Forwarding" or "Virtual Server."
- Enter the external port, internal port, and the device's IP.
- Choose TCP, UDP, or both, depending on the application.
Alternatively, UPnP (Universal Plug and Play) allows applications to automatically request port mappings. It is convenient but can be a security risk if enabled on untrusted networks, as it may allow malware to open ports. Many security experts recommend disabling UPnP on routers that face the internet.
NAT and Security: What It Does and Doesn't Do
NAT provides a basic firewall-like effect: unsolicited incoming packets are dropped because there is no mapping in the translation table. This prevents many external scans from reaching internal devices. However, NAT is not a true firewall. It does not inspect packet content or filter based on application rules. A real firewall can block specific traffic even if NAT is not present. Also, NAT does not protect against malware that initiates outbound connections—those are allowed by NAT. For robust security, you still need a firewall and antivirus software.
Frequently Asked Questions
What does NAT stand for?
NAT stands for Network Address Translation. It is a standard networking term defined in RFC 1631 and later RFC 3022.
Is NAT the same as a firewall?
No. NAT hides internal IPs and drops unsolicited incoming traffic, which gives a firewall-like effect, but it does not filter content or block specific applications. A firewall is a separate security device or software that enforces rules.
Why does my router have a different IP than my computer?
Your computer has a private IP (like 192.168.1.2) assigned by your router's DHCP. Your router has a public IP (assigned by your ISP) that it uses to communicate with the internet. NAT translates between the two.
Does NAT affect internet speed?
In most cases, NAT adds negligible latency because the translation is done in hardware at line speed. However, heavy NAT on a low-end router can slow throughput, especially with many simultaneous connections.
Can I disable NAT on my router?
Some routers allow you to disable NAT, but then your devices will not have internet access unless they have public IPs. Disabling NAT is only useful in specific setups like bridging or when using IPv6.
What is double NAT and how do I fix it?
Double NAT occurs when two routers both perform NAT. You may notice issues with port forwarding or gaming. Fixes include putting the second router in bridge mode, using the first router's DMZ, or enabling IP passthrough on the ISP router.