Get your public IP from the command line
curl, wget, PowerShell, and JSON endpoints for confirming the public IP the internet sees — plus tips for proxies, scripting, and dual stack.
Why your local IP is not your public IP
On most home and office networks, the address shown by `ifconfig`, `ipconfig`, or `ip addr` is a private RFC1918 address such as 192.168.x.x or 10.x.x.x. That address is only meaningful inside your LAN — every device on the public internet sees a different, NAT-translated IP belonging to your router or your ISP.
The public IP is what websites log, what API rate limits apply to, and what geolocation services resolve. When you debug "why is this user blocked" or "why is geo-targeting wrong", that IP — not the LAN one — is the one that matters.
Plain text IP
The fastest check is hitting the root domain. The server inspects the User-Agent and returns either a full HTML page (browser) or just the IP as plain text (curl, wget, PowerShell, Go, Python `requests`, etc.). Plain text means no JSON parsing, no HTML scraping — just echo the result.
This makes it trivial to embed in shell prompts, monitoring scripts, or CI pipelines where you only need the bare IP.
curl https://ipconf.me
wget -qO- https://ipconf.me
powershell -Command "Invoke-RestMethod https://ipconf.me"
# In a script:
MY_IP=$(curl -s https://ipconf.me)
echo "Current public IP: $MY_IP" JSON response with location and ASN
When you need country, region, city, ISP, ASN, or timezone, switch to the JSON endpoint. The response is one flat object, easy to pipe through `jq` or parse in any language.
You can also query an arbitrary IP (not just the caller). This is useful for incident response — given a suspicious IP from your logs, look up the ASN and country in one call.
curl https://ipconf.me/json
curl https://ipconf.me/json/8.8.8.8
# Extract just the country with jq:
curl -s https://ipconf.me/json | jq -r .country
# Add lang=zh for Chinese names:
curl "https://ipconf.me/json?lang=zh" IPv4 and IPv6 checks
If your network has dual stack, curl will pick whichever address family the OS prefers, which is usually IPv6 on modern systems. Force each family explicitly to see both sides.
A mismatch between the two is normal but worth understanding: NAT44 hides every device behind one IPv4 address, while IPv6 typically exposes a unique address per device. VPNs often route only IPv4, leaving IPv6 to leak around them.
curl -4 https://ipconf.me # force IPv4
curl -6 https://ipconf.me # force IPv6
# Side-by-side:
echo "IPv4: $(curl -4 -s https://ipconf.me)"
echo "IPv6: $(curl -6 -s https://ipconf.me)" Through proxies, CDNs, and corporate networks
If you sit behind an HTTP proxy or a corporate egress, the IP the world sees is the proxy's outbound IP, not yours. Set `HTTPS_PROXY` to confirm which IP the proxy presents, and clear it to compare with your direct egress.
Behind Cloudflare or other CDNs, the origin sees the CDN edge IP. ipconf.me honors `CF-Connecting-IP` and `X-Forwarded-For` to surface the real caller — handy if you need to confirm what your origin would record.
# With a proxy set:
HTTPS_PROXY=http://proxy.internal:8080 curl https://ipconf.me
# Without proxy (direct egress):
unset HTTPS_PROXY
curl https://ipconf.me Scripting and monitoring
A common use case is detecting public IP changes — for dynamic DNS, security alerts, or VPN drop monitoring. Save the IP, sleep, re-check, alert on diff.
Keep request frequency reasonable (every few minutes is fine, every second is abuse). If you query from many machines, cache the result locally for the polling interval.
# bash: alert on public IP change
LAST=""
while true; do
NOW=$(curl -s https://ipconf.me)
if [ "$NOW" != "$LAST" ] && [ -n "$LAST" ]; then
echo "IP changed: $LAST -> $NOW" | mail -s "Public IP changed" you@example.com
fi
LAST="$NOW"
sleep 300
done