Skip to content

Find your public IP from the terminal

Your machine knows its local address (192.168.x.x, 10.x.x.x) — but that's not what the internet sees. Your public IP is the address your router or network presents to the outside world. The fastest way to read it is a single request to ipconfig.io.

The one-liner

sh
curl ipconfig.io
203.0.113.42

That's it — the bare address and a newline, nothing to parse. It works the same in a shell, a Dockerfile, an SSH session, or a CI job.

On every platform

sh
curl ipconfig.io
sh
wget -qO- ipconfig.io
powershell
Invoke-RestMethod ipconfig.io

Why not ipconfig or ifconfig?

The built-in ipconfig (Windows) and ifconfig / ip addr (Linux/macOS) commands show your local interface addresses — behind NAT. To see the address the internet sees, you have to ask something on the internet. That's what this service is for.

IPv4 or IPv6 specifically

If your network has both, curl picks one. Force the family with -4 or -6:

sh
curl -4 ipconfig.io     # IPv4 only → 203.0.113.42
curl -6 ipconfig.io     # IPv6 only → 2001:db8::1

This is the quickest way to check whether you have working IPv6 at all — if curl -6 errors, you don't.

Save it to a variable

In scripts, capture the value with -s (silent, no progress meter):

sh
MYIP=$(curl -s ipconfig.io)
echo "Public IP is $MYIP"

A common use is allow-listing your current address — for a firewall rule, a database pg_hba.conf line, or a cloud security group:

sh
echo "My IP for the allow-list: $(curl -s ipconfig.io)/32"

Want more than the address?

ipconfig.io also returns your country, city, network (ASN) and reverse DNS. See Look up IP geolocation with curl, or the full API reference.

Geolocation by MaxMind GeoLite2. No tracking, no keys.