Skip to content
Addressing and routing

· 4 min read

What is NAT, and what is CGNAT?

Network address translation is the reason your whole household can share one public IP address. It works well enough that most people never notice it, until they try to host something, or find that their ISP has put them behind a second layer of it.

On this page

What NAT does#

Network address translation rewrites the addresses in packets as they cross a router. The version almost everyone uses is called port address translation, or NAPT: many private devices share one public address, and the router tells their traffic apart by port number. It was introduced as a stopgap for the IPv4 shortage (RFC 3022) and became permanent infrastructure.

Network address translationThree devices on a home network have private addresses 192.168.1.10, .11 and .12. The router keeps a table that maps each one to a different port on the single public address 203.0.113.42, so the internet sees one address and the router can send each reply to the right device.Laptop192.168.1.10Phone192.168.1.11TV192.168.1.12RouterNAT table.10 ↔ :40001.11 ↔ :40002.12 ↔ :40003The internet203.0.113.42private addressesone public address
The router keeps a table pairing each device with a port on the shared public address.

A translation, row by row#

Suppose the laptop at 192.168.1.10 opens a secure connection to a server at 198.51.100.7. The laptop picks a source port, say 51000. When the packet reaches the router, the router picks its own port, records the pairing, and sends the packet on with its public address as the sender.

One connection, as seen at each end
SourceDestination
Leaves the laptop192.168.1.10:51000198.51.100.7:443
Router's table entry192.168.1.10:51000 ↔ 203.0.113.42:40001
Arrives at the server203.0.113.42:40001198.51.100.7:443
Server's reply198.51.100.7:443203.0.113.42:40001
Delivered to the laptop198.51.100.7:443192.168.1.10:51000

The server only ever sees the public address. The private one is never on the wire outside the home.

The entry is created by an outbound packet and expires when the connection goes quiet. A packet arriving from outside with no matching entry has nowhere to go, and is dropped. This is why devices behind NAT are hard to reach from outside, and it is a side effect, not a design goal.

What NAT changes in practice#

  • Inbound connections fail. To host a game server or a camera, you have to tell the router which port belongs to which device. That is a port forward.
  • Some protocols need help. Voice and video calls, peer-to-peer transfers and online games have to discover their public address and punch holes through the table. They use helper protocols such as STUN and, for UDP, behaviour described in RFC 4787. When you see "NAT type: strict" in a game, this is what it means.
  • Every device looks the same from outside. Websites cannot tell your laptop from your phone by address. They use other signals, such as cookies and fingerprints, to do that.
  • Address reputation is shared. If someone else behind the same public address is abusive, everyone behind it inherits the block.

Carrier-grade NAT#

The same mechanism can be applied twice. When an ISP has too few public IPv4 addresses for all its customers, it puts carrier-grade NAT (CGNAT) in its own network, so hundreds or thousands of subscribers share one public address, and your home router translates once more inside that. Addresses in 100.64.0.0/10 are reserved for the link between the ISP and your router (RFC 6598). Mobile networks use CGNAT almost universally.

How to tell whether you are behind it

  1. Find the address on your router's Internet or WAN page. See how to find your IP address if you are not sure where.
  2. Compare it with the address on the home page.
  3. If they differ, and the router's address is in 100.64.0.0 to 100.127.255.255 or is another private address, you are behind CGNAT or a second router.

What it costs you

  • No inbound connections at all. Port forwarding cannot work, because the router that would have to forward is not yours.
  • A shared reputation. You share an address with strangers, and a block aimed at one of them can catch you.
  • Odd locations. The address belongs to the ISP's exit point, so the city shown by IP geolocation can be somewhere you have never been.
  • Logging difficulty. An address on its own no longer identifies a subscriber. The ISP needs the port and the exact time as well.

Common questions#

Does NAT slow my connection?

The translation itself is negligible on home routers. CGNAT can add a hop and become a bottleneck at busy times, and it makes some services fall back to relayed connections, which are slower.

Do I need NAT with IPv6?

No. IPv6 has enough addresses for every device to have its own globally routable one. A router still blocks unsolicited inbound connections by default, so devices are not exposed simply because they are addressable.

What is double NAT?

Two routers each translating, for example an ISP-supplied box with your own router plugged into it. Everything on the inner network works for browsing and breaks for hosting. Put the ISP box in bridge mode, or plug your router's WAN port into a device that is only a modem.

Try it on your own connection

Sources and further reading

Keep reading

Published by My IP Address