Sub topic 14
Carrier-grade NAT and why port forwarding may not work
This chapter assumes you know private IPv4 ranges, how source NAT and port address translation (PAT) work, and how a port forward is configured on a home router. Here you will see why a correct port forward can still fail when your internet provider adds a second layer of NAT.
What carrier-grade NAT is
Carrier-grade NAT (CGNAT, also called large-scale NAT) is source NAT run by the internet provider. The provider puts many customers behind a small pool of public IPv4 addresses. It does this because it has too few public addresses for every subscriber.
Your home router does PAT as usual. Then the provider's equipment does PAT again on the same traffic. A packet is translated twice on its way out.
The shared address space 100.64.0.0/10
The provider needs addresses between your router and its CGNAT device. It often uses 100.64.0.0/10, a block reserved for this purpose (RFC 6598). It is not a private range like 10.0.0.0/8, and it is not routable on the public internet. Some providers use ordinary private ranges instead.
Why port forwarding fails
A port forward is destination NAT. It only works if a connection from outside can reach your router's WAN address. Behind CGNAT, the WAN address is not reachable from the internet. The provider's NAT has no mapping for an inbound connection, and it does not know which customer should receive it. You also cannot create such a mapping, because you do not control that device.
The result is that your router's port forward is correct, and the service is still unreachable from outside.
How to check whether you are behind CGNAT
Compare the WAN address shown by your router with the address the internet sees.
- Read the router's WAN (internet) IPv4 address in its status page.
- Find your public address from a host on your LAN.
- If the two differ, you are behind some form of NAT. If the router's WAN address is in 100.64.0.0/10, it is almost certainly CGNAT.
# Public address as seen from the internet
curl -s https://ifconfig.me
echo
# Trace the path. A hop in 100.64.0.0/10 suggests CGNAT.
traceroute -n 1.1.1.1Options when you are behind CGNAT
| Option | How it helps | Trade-off |
|---|---|---|
| Ask the provider for a public address | Removes the second NAT layer | May cost extra or be unavailable |
| Use IPv6 | Gives each host a globally routable address | Clients need IPv6 too, and you still need firewall rules |
| Reverse tunnel to a VPS | A server with a public address relays traffic to you | You run and pay for the relay |
| Hosted tunnel or relay service | Same idea, managed for you | Third-party dependency |
| Outbound-only design | Your service connects out to a rendezvous server | Needs a different application design |
A reverse tunnel works because your host opens the connection outward, which CGNAT permits. The relay then carries inbound traffic back over that connection.
Side effects of CGNAT
- Many customers share one public address, so a site may rate-limit or block everyone behind it because of one user.
- Each customer gets only a limited range of ports, so a user with many connections can run out.
- Logging who used an address at a given time requires the provider to record port ranges and timestamps.
Exercise
Your router's WAN address is 100.72.4.18, but a website reports your public address as 198.51.100.9. You configured a correct port forward to a web server on your LAN, and outside users cannot connect. What is the likely cause, and name two ways to make the server reachable?
Show answer
The WAN address is in 100.64.0.0/10, so your provider uses CGNAT. Inbound connections to 198.51.100.9 are not mapped to your router, so your port forward is never reached. You can ask the provider for a public IPv4 address, use IPv6 with a firewall rule allowing the service, or run a reverse tunnel through a public relay such as a VPS.