Think Like a Computer
No ads, no affiliate links, no software recommendations you did not ask for.

What Is NAT? Network Address Translation Explained

Learn what NAT does, why it breaks inbound connections, and what it does and doesn't do for security. Understand the NAT table and common misconceptions.

Network Address Translation (NAT) is the mechanism that lets many devices share one public IP address. When a computer on a private network (like 192.168.1.10) sends a packet to the internet, the router rewrites the source address and port to its own public IP and a new source port. It records that mapping in a table. When the reply comes back, the router looks up the table and forwards the packet to the original device. This is why you can browse the web from every device in your house even though your ISP gives you only one IP address.

The same table is why inbound connections fail. If a computer on the internet tries to start a conversation with your public IP, the router has no entry in its table for that connection. It does not know which device should receive the packet, so it drops it. This is not a malfunction; it is the design. NAT breaks the end-to-end principle of the internet, where any host can reach any other host directly. The table is the price of sharing one IP.

NAT is often described as a security feature, but that description is misleading. NAT does not inspect packets, filter content, or block attacks. It simply does not forward unsolicited inbound traffic because it has no mapping. That behavior provides a de facto barrier, but it is not a firewall. A firewall makes explicit decisions based on rules; NAT makes a mechanical decision based on a table. If you need security, you need a firewall. If you need to allow inbound connections, you need port forwarding or a VPN.

How NAT Works

When a device sends a packet to the internet, the router performs the following steps:

  1. Receives the packet from the private IP (e.g., 192.168.1.10:5000).
  2. Rewrites the source to the router’s public IP and a new source port (e.g., 203.0.113.5:40000).
  3. Records the mapping in the NAT table: (private IP:port → public IP:port).
  4. Forwards the packet to the destination.
  5. Receives the reply addressed to the public IP and port.
  6. Looks up the table to find the original private IP and port.
  7. Rewrites the destination and forwards the packet to the original device.

The table entry is not permanent. It has a timeout, typically a few minutes. If the connection is idle longer than the timeout, the entry is removed. The next packet from the device will create a new mapping.

The NAT Table and Inbound Connections

The NAT table is the reason inbound connections fail. Consider a web server on your private network at 192.168.1.20, listening on port 80. A client on the internet sends a packet to your public IP, port 80. The router receives it, but the table has no entry for that destination. The router has no way to know that the packet is meant for 192.168.1.20. It drops the packet.

To make the server reachable, you must create a static mapping, often called port forwarding. This tells the router: “Any packet arriving on public IP, port 80, forward to 192.168.1.20, port 80.” The router then creates a permanent table entry for that mapping. This is a deliberate exception to the NAT behavior.

What NAT Does and Does Not Do for Security

What NAT doesWhat NAT does not doWhen this does NOT apply
Hides private IP addresses from the internetInspect packet contents for malwareWhen you have a public IP directly on a device (no NAT)
Blocks unsolicited inbound connections by defaultFilter traffic based on rulesWhen you have configured port forwarding
Provides a basic barrier against casual scansProtect against attacks that originate from inside the networkWhen you are using IPv6 (which has no NAT by default)
Allows many devices to share one public IPReplace the need for a firewallWhen you are using a carrier-grade NAT (CGNAT)

NAT is not a firewall. A firewall can block specific IPs, ports, or protocols. NAT cannot. A firewall can log and alert. NAT cannot. If you rely on NAT for security, you have no security. You need a firewall.

Common Misconceptions About NAT

Misconception: NAT is a security feature.

This is the most common mistake. It is a natural one because NAT does block unsolicited inbound traffic, and that looks like protection. But the mechanism is entirely different. A firewall makes decisions based on policy; NAT makes decisions based on a table. The distinction matters because a firewall can be configured to allow or deny specific traffic, while NAT only forwards what it has a mapping for. If you think NAT is protecting you, you might skip setting up a firewall, leaving your network exposed to attacks that NAT does not stop, such as malicious outbound connections or attacks that exploit allowed inbound mappings.

Misconception: NAT is a security feature because it hides your IP.

Hiding an IP is not security. It is obscurity. An attacker can still find your public IP through other means, such as email headers or server logs. And even if they do not know your IP, they can still send you malicious links or exploit vulnerabilities in your browser. NAT does not protect you from these.

Misconception: NAT is only for home networks.

NAT is used in enterprise networks, data centers, and even on the internet itself. Carrier-grade NAT (CGNAT) is used by ISPs to share a single public IP among many customers. This is why you might not be able to host a server even with port forwarding – your ISP is doing NAT on their end, and you cannot control that.

What People Get Wrong About NAT

The biggest misunderstanding is that NAT is a security feature. It is a natural mistake because the observable behavior – unsolicited inbound connections failing – looks like protection. But the mechanism is not designed for security. It is designed for address conservation. The failure of inbound connections is a side effect, not a feature. When you understand that, you can predict what will happen in situations the manual does not cover. For example, if you set up a port forward, you are creating an exception to the NAT behavior. That exception is not filtered by NAT; it is a direct path into your network. If you do not secure the service behind that port forward, you are exposed.

Another common mistake is assuming that NAT provides anonymity. It does not. Your public IP is visible to every server you connect to. The server can see your public IP, and it can correlate your traffic. NAT does not hide your identity; it hides the internal structure of your network.

NAT and IPv6

IPv6 was designed to eliminate the need for NAT. With IPv6, every device can have a unique public IP address. This restores end-to-end connectivity, meaning inbound connections work without port forwarding. However, this also means that devices are directly reachable from the internet, which is why IPv6 networks still need firewalls. NAT is not used in IPv6 by default, but it exists in some transition mechanisms.

NAT and Port Forwarding

Port forwarding is the standard way to allow inbound connections through NAT. It is a static mapping that tells the router to forward specific ports to specific internal IPs. This is how you host a web server, a game server, or a security camera behind NAT. The configuration is done on the router, usually through a web interface. The exact steps vary by router model, but the concept is the same: you specify the external port, the internal IP, and the internal port.

Port forwarding is a deliberate exception to NAT. It creates a permanent table entry. This means that the router will forward all traffic on that port to the specified internal IP, regardless of whether the internal device initiated the connection. This is why port forwarding can be a security risk if you do not secure the service.

NAT and VPNs

A VPN (Virtual Private Network) can be used to bypass NAT restrictions. When you connect to a VPN, your device creates an encrypted tunnel to a VPN server. The VPN server then sends your traffic to the internet. From the internet’s perspective, the traffic comes from the VPN server’s IP, not your public IP. This means that inbound connections to your device are not possible unless the VPN server forwards them, which it typically does not. VPNs are used for privacy and to access geo-restricted content, but they do not solve the inbound connection problem.

NAT and Gaming

Online gaming often requires inbound connections. If you are behind NAT, you may experience issues with matchmaking or hosting games. This is why games often use a technique called “hole punching” or “NAT traversal.” These techniques use a public server to coordinate connections and create temporary mappings in the NAT table. This is not always successful, which is why some games require you to enable UPnP (Universal Plug and Play) on your router. UPnP allows applications to automatically create port forwarding rules. This is convenient but can be a security risk if a malicious application uses it.

NAT and the Internet of Things (IoT)

IoT devices, such as smart cameras and thermostats, often need to be accessed remotely. This is typically done through a cloud service that maintains a persistent connection to the device. The device initiates the connection to the cloud, and the cloud relays commands to the device. This avoids the need for port forwarding. This is why many IoT devices do not require you to configure your router.

NAT and Network Troubleshooting

Understanding NAT can help you troubleshoot network issues. If you cannot connect to a device on your network from the internet, the first thing to check is whether NAT is blocking the connection. If you have port forwarding configured and it is not working, check the internal IP address of the device. It may have changed if it uses DHCP. You can set a static IP or use DHCP reservation to prevent this.

Conclusion

NAT is a fundamental mechanism that allows many devices to share one public IP. It rewrites packet headers and maintains a table to keep track of connections. This table is the reason inbound connections fail by default. NAT is not a security feature; it is an address conservation mechanism. If you need security, use a firewall. If you need inbound connections, use port forwarding or a VPN. Understanding these concepts will help you predict network behavior and troubleshoot issues.

Common questions

What is NAT and why do I need it?

NAT (Network Address Translation) lets multiple devices on a private network share a single public IP address. It rewrites the source address and port in outgoing packets and keeps a table to route replies back. You need it because ISPs typically provide only one public IP per connection, and NAT allows all your devices to use it.

Why can't I connect to my home server from the internet?

Because NAT drops unsolicited inbound connections. The router has no table entry for the incoming packet, so it doesn't know which device to send it to. To fix this, you need to set up port forwarding on your router to direct traffic on a specific port to your server's internal IP.

Is NAT a security feature?

No. NAT blocks unsolicited inbound traffic as a side effect, but it doesn't inspect or filter traffic like a firewall. It provides a basic barrier but doesn't protect against many attacks. You should still use a firewall for security.

What is the difference between NAT and a firewall?

NAT rewrites addresses and maintains a connection table; it doesn't make security decisions. A firewall inspects traffic and applies rules to allow or block based on IP, port, or protocol. NAT is not a substitute for a firewall.

How do I allow inbound connections through NAT?

You need to configure port forwarding on your router. This creates a static mapping that tells the router to forward traffic on a specific public port to a specific internal IP and port. The exact steps vary by router, but the concept is the same.

Read next