[ learn ]

What is NAT and CGNAT?

Updated · 4 min read

Short answer

NAT (network address translation) lets many devices with private addresses share one public IPv4 address: the router rewrites each outgoing packet's source address and port, and maps replies back to the right device. CGNAT (carrier-grade NAT) is the same idea run by the ISP, so many customers share a pool of public addresses, using the range 100.64.0.0/10 between the customer and the ISP.

How NAT works

Your phone at 192.168.1.20 opens a connection from its port 51000 to a web server. The router replaces the source with its public address and a free port, and records the mapping:

inside:   192.168.1.20:51000   →  203.0.113.80:443
outside:  198.51.100.7:40001   →  203.0.113.80:443     (rewritten by the router)
table:    198.51.100.7:40001   ⇄  192.168.1.20:51000

When the reply comes back to port 40001, the router looks up the table and forwards it to the phone. Because ports tell connections apart, one public address can carry thousands of connections from many devices at once. Strictly this is NAPT or "port address translation", but everyone calls it NAT.

Why NAT exists

NAT was a stopgap for the shortage of IPv4 addresses: instead of one public address per device, a household or office needs one in total, and uses the private ranges inside. It became so common that almost every home router does it by default. A side effect is that unsolicited incoming connections are dropped, because there is no table entry telling the router where to send them.

Carrier-grade NAT

With IPv4 exhausted, ISPs cannot give every customer a public address either. With CGNAT the customer's router gets an address from 100.64.0.0/10 (shared address space, RFC 6598) or another internal range, and the ISP's large NAT gateways translate it again into a public address shared by many customers. A home on CGNAT therefore goes through two translations, sometimes called NAT444. Mobile networks have worked this way for a long time; many broadband ISPs now do too.

Side effects

  • No incoming connections. Port forwarding on your router does nothing behind CGNAT, so hosting a game server, a camera or a home server needs IPv6, a tunnel, or a paid public IPv4 address from the ISP.
  • Shared reputation. Everyone behind a CGNAT address looks like one visitor. If one person spams or attacks, the address can be rate-limited, shown CAPTCHAs or flagged as an abuser, affecting everyone else on it. That is one cause of false positives in VPN and abuse detection.
  • Less precise location. One gateway can serve a whole region, so geolocation of CGNAT addresses is coarse.
  • Logging burden. To identify a user later, an ISP must log the address, the port and the exact time, not just the address.
  • Some applications break, especially peer-to-peer and VoIP, which then fall back to relays.

How to tell if you are behind CGNAT

  1. Log in to your router and note its WAN (internet) address.
  2. Open What is my IP? and compare.

If the router's WAN address is in 100.64.0.0/10 (100.64.0.0 to 100.127.255.255), in a private range, or simply different from the public address you see here, you are behind CGNAT. A traceroute that shows several private or 100.64 hops before reaching the ISP's public network is another sign.

IPv6 and NAT64

IPv6 has enough addresses that NAT is not needed: every device gets a public address, and the router's firewall blocks unwanted incoming traffic instead. IPv6-only mobile networks use NAT64 with DNS64 in the other direction, to let IPv6 phones reach IPv4-only sites through a translator using the prefix 64:ff9b::/96. If you have IPv6, sites that support it see your own address rather than a shared one.

[ FAQ ]

Frequently asked questions

Is NAT a firewall?

Not really, though it has a similar effect: devices behind NAT cannot be reached by unsolicited incoming connections. Routers combine NAT with a stateful firewall, and with IPv6 the firewall does that job on its own.

How many users share one CGNAT address?

It depends on the ISP. Each address has about 64,000 ports, and ISPs typically allocate a block of ports per customer, so one public address commonly serves dozens to hundreds of customers at once.

Can I get out of CGNAT?

Many ISPs offer a public IPv4 address on request or for a fee, especially on business plans. Using IPv6, if your ISP offers it, also gives you directly reachable addresses.

Why does port forwarding not work on my router?

If your ISP uses carrier-grade NAT, incoming connections are stopped at the ISP's gateway before they reach your router, so router port forwarding has no effect. Check whether your router's WAN address is in 100.64.0.0/10.

Last updated · All articles · API docs