Public vs private IP addresses (and why yours keeps changing)

By Jelle · Updated

Your laptop and the website you are reading do not see the same address for you. Your device has a private address on your local network, while the internet sees a public one that belongs to your router or provider.

Private address ranges

Three IPv4 ranges are reserved for private networks (RFC 1918). They are never routed on the public internet, so every home and office can reuse them:

RangeAddressesOften seen in
10.0.0.0/810.0.0.0 to 10.255.255.255Companies, VPNs
172.16.0.0/12172.16.0.0 to 172.31.255.255Docker, cloud networks
192.168.0.0/16192.168.0.0 to 192.168.255.255Home routers

A few other special ranges look similar: 127.0.0.0/8 is loopback (your own machine), 169.254.0.0/16 is link-local (what a device assigns itself when DHCP fails), and 100.64.0.0/10 is shared address space used by providers for carrier-grade NAT.

How NAT connects the two

Your router has one public address on the outside and a private address on the inside. When a device sends a request, the router rewrites the source address to the public one and remembers the connection. When the answer returns, it translates back and forwards it to the right device. This is network address translation, and it is why dozens of devices can share a single public address.

Why your public IP changes

Carrier-grade NAT and port forwarding

Some providers put many customers behind one public address (CGNAT). The result is that your router's own "public" address is actually in the 100.64.0.0/10 range or otherwise differs from what the internet sees. Port forwarding and self-hosting then do not work from outside, because the provider's equipment sits in the way.

A quick check: compare the WAN address shown in your router's status page with the answer from the IP service. If they differ, or the WAN address is private, you are behind CGNAT. Ask the provider for a public address, use IPv6 if it is available, or use a tunnel.

See both addresses yourself

# Private address(es) on this machine
ip -4 addr          # Linux
ipconfig            # Windows

# Public address as seen from the internet
curl -4 -s https://whatsmyip.haasje.net

More ways to run the public lookup, including a script that warns when it changes, are in the guide on checking your IP from the terminal.

Dynamic or static?

If you host something at home, a changing address is annoying. Dynamic DNS fixes this: a small client updates a hostname whenever your public address changes, so you connect by name. Some providers also sell a fixed address for a fee.

What your public IP reveals

Your public address tells a website roughly which provider and region you are in, usually the country and sometimes the city, but not your street address. It is not secret, and it is no reason to panic. A private address, on the other hand, is not a security measure: a device on a private network can still be attacked through your router if something is forwarded to it.