Self Hosting Behind CGNAT: Why Port Forwarding Fails and What Works
Self hosting behind CGNAT fails in one way: the service runs, it answers on the home network, and nothing from the internet gets in. The usual cause is carrier-grade NAT (CGNAT): network address translation done a second
Self hosting behind CGNAT fails in one way: the service runs, it answers on the home network, and nothing from the internet gets in. The usual cause is carrier-grade NAT (CGNAT): network address translation done a second time inside the provider's network, so several households appear on the internet as one IPv4 address. A forwarding rule on your router cannot fix that, because the packet is dropped upstream of your router. Connections you start from inside still work, so browsing and SSH out look fine and the fault looks like a bad rule.
Everything you can change on your own router sits on the wrong side of the problem. A working option either gives the line a routable address, public IPv4 or IPv6, or makes the connection start from inside.
How to check for CGNAT: compare two addresses
The check needs two addresses: the one your router holds on the provider side, and the one the rest of the internet sees.
- Find the WAN (sometimes Internet) IPv4 address on the router's status page.
- On a device in that network with no VPN running, open a what-is-my-IP page to see the address the internet sees.
- Compare the two.
- A WAN address that starts 100.64 through 100.127 means CGNAT. That block, 100.64.0.0/10, goes by Shared Address Space in RFC 6598. It is reserved for the link between a provider's NAT and the customer's router and is not forwarded between providers.
- A WAN address equal to the one the internet sees means the router has a public address, and a forwarding rule can work.
- A WAN address in a private block (10.x, 172.16.x through 172.31.x, or 192.168.x) means another NAT is upstream: a second router or provider box in your home, or a provider NAT on lines where it manages the router.
- A public WAN address that does not match means something translates it again, for instance a VPN running on the machine you tested from.
Without access to the router, traceroute can hint: a hop just past it inside 100.64.0.0/10 points to CGNAT, but silent hops stay hidden and a provider can use that block elsewhere, so only the WAN address settles it. One trap: a 100.x address on a laptop or phone is usually Tailscale, which hands every device an address in that same block. The full CGNAT guide adds how to run the check on a phone or hotspot.
CGNAT vs double NAT
Double NAT puts two NATs on your side of the line, typically a provider modem-router with a router of your own behind it. You can fix that yourself: switch the first box to bridge mode or forward the port on both. CGNAT produces the same symptom with the second NAT in the provider's network, which the provider alone controls.
What CGNAT breaks and what it leaves alone
Outbound traffic is untouched. A carrier-grade NAT creates a mapping when a device inside sends a packet, and replies use it to come back. Web, email, package managers, SSH out and a VPN client all begin on your side.
Whatever waits for a stranger to connect breaks: a web server, SSH in, a WireGuard or OpenVPN endpoint at home, remote desktop, a camera or NAS app that dials in.
Peer-to-peer and real-time features fall in between. Apps that both send first can often connect through NAT traversal (STUN and ICE), with a relay server as the fallback if the app has one. Some torrent clients cannot seed, some VoIP (SIP) clients cannot receive calls unless they send first or ask the NAT for a port, and some console games fail when two players share an outside address.
A shared address has side effects too. Rate limits, CAPTCHAs and blocklists keyed to an address treat your neighbours' traffic as yours, and geolocation points at the provider's NAT. Providers can cap the ports per customer, and above the cap new connections are dropped.
Why CGNAT port forwarding fails
A forwarding rule is a static mapping on your router: traffic arriving at one port of the WAN address goes to one device. Behind CGNAT it never gets that far. The provider's NAT sees a connection nobody inside started, has no mapping for it and drops it. Everything that edits your own side does nothing: forwarding rules, UPnP, a DMZ host, a new router, a factory reset. Dynamic DNS fails too: it publishes an address, and on a CGNAT line that address is the shared one. A correct rule next to a port that stays closed is the classic sign, so read the WAN address first.
PCP, the Port Control Protocol, is the one mechanism that reaches the right NAT: it lets a host request a mapping. A carrier-grade NAT must give subscribers some protocol for controlling mappings, and PCP is the recommended one. Support depends on the provider.
Self hosting behind CGNAT: five ways in compared
| Option | What it takes | Who can connect | Trade-offs |
|---|---|---|---|
| Public IPv4 from the provider | A request or a plan change. Price and availability vary. Starlink offers it to Local and Global Priority customers | Anyone, on the ports you forward | Forwarding works as before, and so does the exposure. Forward single ports and patch what listens |
| IPv6 | A prefix routed to your router, and IPv6 on the visitor's side | Anyone with IPv6, direct to the server | Only the router's IPv6 filter stands in the way. IPv4-only visitors cannot connect |
| Outbound tunnel to a provider's edge (Cloudflare Tunnel) | A small daemon at home and a DNS name pointed at the tunnel | Anyone, through the provider's network | A reverse proxy sits in the path. On Free, Pro and Business tiers, video and other large files over a public hostname require a specific paid service |
| Rented relay (VPS plus WireGuard) | A small server with a public IPv4 and a tunnel from home that stays up | Anyone, on the ports forwarded on the VPS | A monthly bill, a machine to patch, a longer path. Any TCP or UDP port works. Keepalives from home, 25 seconds being common, hold the mapping |
| Overlay network (Tailscale) | A client on each device | Your own devices and people you add | No inbound port has to be opened at home. Direct paths when NAT traversal works, relays otherwise. Public sharing (Funnel) is TLS only, on 443, 8443 and 10000 |
The last three need no open port at home, because the connection always starts from the home side. If only you and a few people connect, an overlay network keeps the service private by default. A public web service fits IPv6, a tunnel provider or a VPS. A raw TCP or UDP service for outside users is the hard case, and it fits a VPS forward or a public IPv4 address.
IPv6: no NAT, but check the firewall
A line can be CGNAT on IPv4 and still carry native IPv6, because providers run the two side by side. Global IPv6 addresses currently begin with 2 or 3, so look for one on the router's status page. Each device then has its own address and needs no mapping.
The first catch is the firewall. With no NAT, the router's IPv6 filter is the only gate. The usual pattern for home gateways is stateful filtering that admits traffic only when someone inside started it, plus manual exceptions, and whether a given router ships with it enabled is left to the vendor. Read its IPv6 firewall page, allow one port to one address and leave the filter on. The second catch is the far end: visitors need IPv6 too, and a prefix that changes needs an AAAA (IPv6) DNS record that follows it.
Test the result from another network
A test from inside that targets your own public address relies on NAT loopback and can mislead. The port scan on packet.guru is a TCP-only check: give it a hostname or an IPv4 address and up to 10 ports per scan, and each port comes back open, closed or filtered, where filtered means a firewall dropped the probe silently. It is meant for hosts you control or may test, so point it at the VPS or a public IPv4 address your provider assigned. IPv6 rules and UDP services need another test, such as a friend connecting from their own network.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.