Networking

Public vs private IP: NAT, CGNAT and what your IP reveals

If you have ever seen your computer with an address starting with 192.168, while a “what is my IP” site shows a completely different number, you found the distinction between private IP and public IP. The two coexist by design: one identifies the device inside your local network; the other identifies your connection to the rest of the internet. But that distinction hides three layers almost nobody explains properly. First: which blocks are private and why they were reserved. Second: how NAT actually works, port translation, state table, and why it breaks inbound connections (and why it is not a firewall, despite the myth). Third: CGNAT, the reason the “public” IP you see may not be yours, and what it ruins. Finally, what an IP truly reveals about you: less than you fear, and in a different way than you imagine. Drop your real number into the [“what is my IP”](tool:meu-ip) tool and follow along.

J-Kit16 min readIntermediate
  • IP address
  • NAT
  • CGNAT
  • RFC 1918
  • Networking

Key takeaways

  • A public IP is unique and routable on the internet; a private IP (RFC 1918: 10/8, 172.16/12, 192.168/16) is reusable and only works inside the LAN.
  • NAPT shares one public IP by translating the port and keeping a state table; that is why unsolicited inbound connections simply drop.
  • NAT is not a firewall: the protection comes from stateful filtering, not from address translation (RFC 4864).
  • With CGNAT (100.64.0.0/10, RFC 6598) your “public” IP is shared; and IP geolocation points at the provider’s block/ASN, not your home.

Unique vs reusable addresses

The whole internet rests on one simple rule: every public address must be globally unique, otherwise routing has no idea where to send the packet. Private addresses invert that rule on purpose. They are not unique, they are reusable. The same 192.168.0.1 lives in the router of millions of homes at once, and nobody collides, because that number never leaves the local network. It is this difference of scope, not of format, that separates the two. Both look like four identical octets; what changes is where they mean something.

Public IP

  • Globally unique and routable on the internet.
  • Handed out by providers and regional registries (RIRs).
  • One per connection, or shared by many via CGNAT.
  • It is what the server on the other end sees as your source.

Private IP

  • Only meaningful inside the local network.
  • Reusable: 192.168.0.0 appears in millions of networks.
  • Does not travel the internet directly; needs NAT to get out.
  • It is what ipconfig/ifconfig shows, assigned by DHCP.

It is worth killing a vocabulary myth: a private IP is not “insecure” or “bad”, and a public one is not “better”. They are roles. The private one exists precisely so you do not burn a global public address every time you plug in a smart bulb. And because the public IPv4 space is finite and has run out, that thrift stopped being a convenience and became a necessity, as we will see when we reach NAT and CGNAT.

Which blocks are private, and why

RFC 1918 (February 1996) reserves three blocks for private use. Having them in three sizes is practical: a multinational uses the giant 10/8; a mid-size company, the 172.16/12; your home, a slice of 192.168/16. Together they are 17,891,328 addresses any network can reuse without asking anyone, because no router on the internet will forward them. Alongside them sit other blocks that are also not “normal” public addresses, and recognizing them saves confusion when you diagnose a problem.

The most common reserved IPv4 blocks. The first three are the RFC 1918 private ranges; the rest are neighbors that also do not route publicly. Counts are 2 to the power of the host bits.
BlockRFCPurposeAddresses
10.0.0.0/8RFC 1918Large private network16,777,216 (2²⁴)
172.16.0.0/12RFC 1918Medium private network1,048,576 (2²⁰)
192.168.0.0/16RFC 1918Home/small network65,536 (2¹⁶)
100.64.0.0/10RFC 6598CGNAT shared address space4,194,304 (2²²)
127.0.0.0/8RFC 6890Loopback (the host itself)16,777,216 (2²⁴)
169.254.0.0/16RFC 3927Link-local (APIPA, no DHCP)65,536 (2¹⁶)
192.0.2.0/24 · 198.51.100.0/24 · 203.0.113.0/24RFC 5737Documentation (TEST-NET-1/2/3)256 each
Link-local (169.254.0.0/16)
The address a host gives itself when DHCP fails (APIPA). If your IP starts with 169.254, the router did not hand you one, it is a symptom, not a setting.
Loopback (127.0.0.1)
The machine’s “myself”: the packet never even touches a cable. The entire /8 is loopback, not just .0.0.1.
Documentation (TEST-NET)
Blocks reserved for examples (like the ones in this article), precisely so they never collide with anyone’s real addresses.

To plan how to carve one of these ranges into smaller subnets, how many hosts fit in a /26, where the network and broadcast addresses land, the subnet calculator does the math, and the CIDR and subnetting guide explains the mask behind it.

NAT for real: port, state table and the packet both ways

If private addresses do not travel the internet, how does your laptop open a website? Through NAT (Network Address Translation), performed by the router. There are two flavors. In basic NAT (1:1), a private address maps to a whole public address, an identity swap, one for one. What almost everyone actually uses, though, is NAPT (Network Address Port Translation), defined by RFC 2663 and detailed in RFC 3022: it multiplexes dozens of private hosts onto a single public IP, telling each flow apart by port. That is how an entire street browses on one address. The trick is a state table: for every outbound connection, the router records who asked, for where, and under which external port it rewrote the packet.

Basic NAT (1:1)
One private address ↔ one whole public address. Translates only the IP. Needs one public address per host going out at the same time.
NAPT / PAT (overload)
Many private ↔ one public, told apart by port. It is the “NAT” of your home router. Translates IP and port together.
State table
NAT’s memory: it links (internal IP:port, destination) to (external IP:port). With no entry, a returning packet has no idea who to go to.

Let us trace a real packet. Your host 192.168.0.10 picks an ephemeral source port, 51000, and wants to talk to a web server at 203.0.113.25:443. The router’s public IP is 198.51.100.7 (I use documentation addresses only). Follow the translation outbound and inbound, and note the last block: a packet arriving with no match in the table has no destination and is dropped. That drop is the technical reason inbound connections “don’t get through”.

// Exemplo trabalhado 1, tabela NAPT do roteador e o caminho do pacote
// Worked example 1, router NAPT table and the packet path

+----------------------+----------------------+--------------------+
| Interno (LAN)        | Externo (WAN)        | Destino / Dest.    |
+----------------------+----------------------+--------------------+
| 192.168.0.10:51000   | 198.51.100.7:47000   | 203.0.113.25:443   |
+----------------------+----------------------+--------------------+

IDA / OUTBOUND
  LAN  ->  src 192.168.0.10:51000   dst 203.0.113.25:443
  (o NAT reescreve a origem / NAT rewrites the source)
  WAN  ->  src 198.51.100.7:47000   dst 203.0.113.25:443

VOLTA / RETURN  (o servidor responde para o IP:porta externo)
  WAN  <-  src 203.0.113.25:443     dst 198.51.100.7:47000
  (o NAT procura a porta 47000 na tabela / NAT looks up port 47000)
  LAN  <-  src 203.0.113.25:443     dst 192.168.0.10:51000

ENTRADA NAO SOLICITADA / UNSOLICITED INBOUND
  WAN  <-  src ????                 dst 198.51.100.7:47000
  (sem par na tabela / no matching state entry)  ->  DESCARTADO / DROPPED
External port 47000 is the key: it is what lets the router return the reply to the right host. With no matching entry, the inbound packet has nowhere to go.

The myth: “I’m behind NAT, so I’m safe”

The drop you saw above looks like protection, and that is where the myth comes from. If unsolicited inbound connections fall, NAT must be a firewall, right? No. The drop is a side effect of there being no mapping, not a security policy. Nobody in NAT decided “this is malicious, block it”; there simply was nowhere to deliver the packet. The distinction matters because the same protection, and better, exists with no NAT at all, and vanishes the moment a mapping is opened.

NAT (address translation)

  • Real goal: conserve public IPs, not protect.
  • Blocks inbound by accident, only because there is no mapping.
  • Does not inspect content nor have per-port/source rules.
  • One open mapping (port forward, UPnP) already exposes the host.

Stateful firewall

  • Goal: decide by policy what comes in and what goes out.
  • Refuses the unsolicited as an explicit rule, not by accident.
  • Works with or without NAT, including on IPv6, which needs no NAT.
  • Allows controlled exceptions (ports, IPs, directions).

CGNAT: when your “public” IP is not yours

IPv4 has run out, literally. IANA handed the last five /8 blocks to the regional registries on 3 February 2011, and since then each RIR drained its stock on different dates. With no public addresses to give each subscriber, providers began doing NAT en masse inside their own network: CGNAT (Carrier-Grade NAT). RFC 6598 (April 2012) reserved the 100.64.0.0/10 block precisely for this. The result: your router gets an address from that block (or an RFC 1918 one) on its WAN interface, and hundreds of customers share a handful of real public IPs up at the provider. The “my IP” you see is, in practice, rented and shared.

  1. Feb 1996RFC 1918

    The private ranges are formalized, the first stopgap for IPv4 scarcity.

  2. 1999–2001NAT/NAPT standardized

    RFC 2663 and RFC 3022 define the terminology and the traditional NAT running in your router.

  3. 3 Feb 2011IANA depletes the central pool

    IANA hands the last five /8s to the RIRs; the global stock is gone.

  4. Apr 2012RFC 6598, CGNAT

    The 100.64.0.0/10 block is reserved for carrier-grade NAT.

  5. 6 Jun 2012World IPv6 Launch

    Major sites and providers turn on IPv6 for good, the real way out of the dead end.

  6. 25 Nov 2019Europe (RIPE) runs dry

    The RIPE NCC makes its last /22 allocation; only transfers and waiting lists remain.

  7. 2026IPv6 nears half of traffic

    IPv6 traffic measured by Google approaches 50%, but IPv4 and CGNAT are still going strong.

How do you know you are behind CGNAT? Compare two numbers. Open the router admin panel and read the WAN interface IP; suppose it shows 100.83.14.6. Now open the “what is my IP” tool, which reports, say, 187.62.200.45. Two signs seal the diagnosis: (1) the two numbers differ, which already points to another NAT layer above your router; and (2) the WAN IP, 100.83.14.6, falls within 100.64.0.0 to 100.127.255.255 (the second octet, 83, is between 64 and 127), i.e., it is RFC 6598 shared space. If the WAN were a routable public IP equal to what “what is my IP” shows, you would have an address of your own. Since it is not, the provider is doing CGNAT, and no port forwarding on your router fixes it, because the translation that matters happens above you.

A second clue: run a reverse (PTR) lookup on your public IP. The name the provider returns often gives away the connection’s nature, fragments like “cgn”, “cgnat”, “pool” or “dyn” signal shared or dynamic addressing.Open the tool full page
What CGNAT breaks in practice

Anything that depends on someone starting a connection from outside to you. Hosting at home (a site, game server, camera, NAS) becomes unworkable, because your router’s port forwarding cannot reach the provider’s translation. Games with direct peer-to-peer connections fall to a “strict” NAT, with poor matchmaking and broken voice chat. Remote access (SSH, RDP, inbound VPN) does not work without a middleman.

The common ways out: ask (and often pay) the provider for a dedicated public IPv4; use IPv6, which gives every device its own address and sidesteps CGNAT when both ends support it; or a tunnel/relay service that accepts the connection on a server with a public IP and forwards it to you.

Why your public IP changes on its own

Public IPv4 addresses are almost never fixed for residential customers. The provider keeps a pool and lends one per session via DHCP, with a lease time. On rebooting the router, dropping the link, or lease expiry, you may get a different one. With CGNAT the visible IP can change even more often, because it is managed in bulk. That is why dynamic DNS services exist: they update a name whenever the number changes. A fixed IP, when available, is usually a separate paid product.

What an IP really reveals about you

We reach the most common fear: “so anyone can find where I live from my IP?”. No. IP geolocation does not read a GPS; it queries a database that maps address blocks to locations, and that location is the provider’s and the block’s, the ASN (autonomous system number) and the registered allocation, not your street. An entire block of your provider may be mapped to a city center or the ISP’s headquarters, hundreds of kilometers from where you are. CGNAT and VPN make the imprecision worse: your exit appears at the provider’s PoP (point of presence) or the VPN server, not near you. The IP locator shows this estimate, treat it as an “approximate region”, never as an address.

99.8%accuracy at the country level (MaxMind)
66%city hit within 50 km, in the US
0homes or streets an IP identifies

The numbers come from MaxMind’s own accuracy documentation, an industry leader: around 99.8% correct at the country level, but only ~66% city accuracy within a 50 km radius in the US, and the company is explicit that the data is “never precise enough to identify or locate a specific household, individual, or street address”. In other words: the IP hands over country, provider and a coarse region. What actually leaks your exact location is usually something else, the EXIF metadata of a photo with GPS, for instance, points at the house with a precision no IP reaches.

What geolocation really knows (and does not)

It knows: the country (with high confidence), the provider and the ASN, and an approximate region, city or metro area, often the block’s centroid. It does not know: your address, your name, who you are. What the database holds is “this block belongs to such ISP and was registered in such city”, and that is inherited by every customer of that block. That is why neighbors can “show up” in different cities and you, sometimes, in the state capital.

IPv6 changes the framing, not the principle. With 128 bits, each device can have its own global address, no NAT, the “private” equivalent is the Unique Local Address (fc00::/7). This improves end-to-end connectivity and gives port forwarding back, but it also makes a stateful firewall indispensable, since every device becomes directly addressable. IPv6 geolocation tends to be just as coarse or coarser, because the blocks are enormous.

  • IP starting with 10, 172.16–31 or 192.168? It is private (RFC 1918), not what the internet sees.
  • WAN IP in 100.64–127? You are on CGNAT: local port forwarding is useless.
  • IP starting with 169.254? DHCP failed; it is a symptom, not a valid address.
  • Need to expose a service at home? Confirm you have a real public IP before configuring ports.
  • Worried about privacy? The IP gives country and provider, not your street, the bigger care is EXIF and logins.

Frequently asked questions

Why does ipconfig show a different IP than a “what is my IP” site?
Because ipconfig shows your machine’s private LAN IP (something like 192.168.0.15), and the site shows the connection’s public IP as seen from outside. The router’s NAT bridges the two, translating the private address into the public one on every outgoing packet.
Does being behind NAT make me safe?
Not on its own. NAT drops unsolicited inbound connections as a side effect (there is no mapping), not as a security policy. RFC 4864 says address translation “does not provide security in itself”, the real protection comes from a stateful firewall. A port-forwarding rule, UPnP or malware started from inside pierce that false protection.
How do I know if I am behind CGNAT?
Compare your router’s WAN interface IP with what the “what is my IP” tool reports. If they differ, and the WAN IP is in the 100.64.0.0/10 range (RFC 6598) or a private range, the provider is doing CGNAT. In that case, port forwarding on your router will not expose services, because the decisive translation happens in the provider’s network.
Why is it hard to host a server at home?
Because NAT only creates entries for connections that left from inside, so a connection from outside has no match in the table and drops. Port forwarding fixes this, but only if you have a real public IP. With CGNAT you do not, and the provider’s translation ignores your rules. The ways out are a dedicated IPv4 (paid), IPv6, or a tunnel/relay.
Can someone find my exact address from my IP?
No. IP geolocation maps blocks to the provider/ASN location, not your home, and is off by tens or hundreds of kilometers, with CGNAT and VPN, even more. MaxMind, an industry leader, states the data is never precise enough to identify a household or a street address. The IP hands over country, provider and a coarse region.
Is 192.168.0.1 a public IP?
No. 192.168.0.0/16 is a private range (RFC 1918), used on local networks and not routable on the internet. That is why the same 192.168.0.1 appears in the router of millions of homes at once without colliding.

A private IP is valid only inside your network (RFC 1918 ranges: 10/8, 172.16/12, 192.168/16) and is reusable; a public IP is unique and routable. NAPT bridges the two by translating the port and keeping a state table, which is why unsolicited inbound connections drop, and why NAT is not a firewall (the protection is stateful filtering, RFC 4864). With IPv4 exhausted, CGNAT (100.64.0.0/10) makes your “public” IP shared, breaking port forwarding, games and home hosting. And in the end, an IP reveals country, provider and an approximate region of the block/ASN, never your home.

Sources & references

  1. RFC 1918, address allocation for private internets
  2. RFC 6598, shared address space (CGNAT)
  3. RFC 6890, special-purpose IP address registries
  4. RFC 2663, NAT terminology (Basic NAT and NAPT)
  5. RFC 3022, Traditional IP NAT
  6. RFC 4864, NAT is not security; protection comes from stateful filtering
  7. MaxMind, IP geolocation accuracy