Appearance
Find your public IP from the terminal
To find your public IP address from the terminal, run curl ipconfig.io. It returns the address the internet sees for you as plain text — on Linux, macOS, or Windows. Your machine only knows its local address (192.168.x.x, 10.x.x.x); your public IP is what your router presents to the outside world, and the fastest way to read it is a single request.
Maintained by the ipconfig.io team · Reviewed 17 June 2026
sh
curl ipconfig.io203.0.113.42The response is 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.
How do I get my public IP on Linux, macOS, and Windows?
Use the HTTP client your platform already ships with — all three print the same plain-text address:
sh
curl ipconfig.iosh
wget -qO- ipconfig.iopowershell
Invoke-RestMethod ipconfig.ioWhat is the difference between my public IP and my local IP?
Your public IP is the globally routable address the internet sees; your local IP is a private address that exists only inside your own network. Local addresses come from the ranges reserved in RFC 1918 — 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 — and are reused on millions of networks behind NAT, which is exactly why the built-in tools mislead you here:
| Command | Shows | Example |
|---|---|---|
ipconfig (Windows) | Local interface | 192.168.1.20 |
ifconfig / ip addr (Linux/macOS) | Local interface | 10.0.0.5 |
curl ipconfig.io | Public IP | 203.0.113.42 |
To see the address the internet sees, you have to ask something on the internet.
How do I get only my IPv4 or only my IPv6 address?
Force the address family with curl's -4 or -6 flag:
sh
curl -4 ipconfig.io # IPv4 only → 203.0.113.42
curl -6 ipconfig.io # IPv6 only → 2001:db8::1This is also the quickest way to check whether you have working IPv6 — if curl -6 errors, you don't. IPv6 is no longer niche: roughly 50% of users reached Google over IPv6 in 2026 (Google IPv6 statistics), so it's worth confirming both families work.
How do I save my public IP to a variable in a script?
Capture the output with command substitution and curl's -s (silent) flag:
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 PostgreSQL pg_hba.conf line, or a cloud security group:
sh
echo "My IP for the allow-list: $(curl -s ipconfig.io)/32"Frequently asked questions
What is the command to find my public IP address? Run curl ipconfig.io. It prints your public IP as plain text with a trailing newline and nothing else, ready to use in a script.
Why does ipconfig or ifconfig show a different IP? Those commands show your local interface address behind NAT (like 192.168.x.x). The public address the internet sees comes only from asking a server on the internet.
How do I get only IPv4 or only IPv6? Use curl -4 ipconfig.io or curl -6 ipconfig.io. If the -6 form errors, your network has no working IPv6.
Next steps
Your IP is only the start — ipconfig.io also returns your country, city, network (ASN), and reverse DNS. See how to look up IP geolocation with curl, read what an ASN is and how to find yours, or browse the full API reference.