net&sky

What is my IP address? From the command line

Get your public IP address, IPv4 or IPv6, country and more in plain text with curl, wget or PowerShell. Made for terminals and scripts: one line in, one line out, no ads, no sign-up.

Commands

curl netandsky.com/ipyour public IP address (IPv6 if your connection has it)
curl -4 netandsky.com/ipyour IPv4 address only
curl -6 netandsky.com/ipyour IPv6 address only
curl netandsky.com/ip.jsonIP, country, city, region and time zone as JSON
curl netandsky.com/countrytwo-letter country code, e.g. IN
curl netandsky.com/uayour user agent, as servers see it
curl netandsky.comthis list, in the terminal
$ curl netandsky.com/ip
203.0.113.25

$ curl netandsky.com/ip.json
{"ip":"203.0.113.25","country":"IN","city":"Hyderabad","region":"Telangana","timezone":"Asia/Kolkata"}

Windows

irm netandsky.com/ipPowerShell (Invoke-RestMethod)
(irm netandsky.com/ip.json).countryPowerShell, one field from the JSON
curl.exe netandsky.com/ipCommand Prompt or PowerShell, Windows 10 and 11

In Windows PowerShell 5, curl on its own is a different command; use curl.exe or irm.

Linux and macOS

wget -qO- netandsky.com/ipwith wget
curl -s netandsky.com/ip.json | jq -r .countryone field, with jq
dig +short myip.opendns.com @resolver1.opendns.comno website at all: ask OpenDNS (IPv4)

In scripts

# Bash: save your address, and notice when it changes
IP=$(curl -fsS --max-time 10 netandsky.com/ip) || exit 1
[ "$IP" != "$(cat ~/.lastip 2>/dev/null)" ] && echo "IP changed to $IP" && echo "$IP" > ~/.lastip
# Python
import urllib.request
ip = urllib.request.urlopen("https://netandsky.com/ip", timeout=10).read().decode().strip()
# PowerShell
$ip = (Invoke-RestMethod https://netandsky.com/ip).Trim()

Use https:// in scripts that send the result anywhere. Please check at most once a minute; for more, run your own.

Questions

Why does it show an IPv6 address?

Your connection has both, and it reached us over IPv6, which most Indian mobile and many broadband networks now prefer. Add -4 for the IPv4 address.

Is it the same as ifconfig.me or icanhazip.com?

It works the same way: the address your connection arrives from, in plain text. The JSON also gives your country, city and time zone.

Do you keep my IP address?

No. The answer is sent straight back and IP addresses are not written to our logs. See About & privacy.

In a browser?

The My IP page shows the same, with your device and browser details.