DEV Community

CodeLong888
CodeLong888

Posted on

Check your IP, ASN, and VPN/proxy leaks from the terminal with curl (no signup, no key)

Every "what's my IP" site is a bloated page covered in ads, cookie banners, and "sign up for a VPN" popups. Half the time I just want the number, and often I want it inside a shell script or over SSH, where a browser is not even an option.

So here is the no-nonsense version: hackmyip.com serves clean text and JSON when you hit it with curl. No signup, no API key, no HTML.

The basics

# IP + location + network, human-readable
curl hackmyip.com

# just the raw IP (pipe-friendly)
curl hackmyip.com/ip
# 203.0.113.45
Enter fullscreen mode Exit fullscreen mode

Because /ip returns nothing but the address, it drops straight into scripts:

IP=$(curl -s hackmyip.com/ip)
echo "running from $IP"
Enter fullscreen mode Exit fullscreen mode

JSON when you need to parse it

curl hackmyip.com/json
Enter fullscreen mode Exit fullscreen mode
{
  "ip": "203.0.113.45",
  "city": "Amsterdam",
  "country": "NL",
  "asn": "AS64500",
  "org": "Example Telecom B.V."
}
Enter fullscreen mode Exit fullscreen mode

Pipe it into jq like anything else:

curl -s hackmyip.com/json | jq -r .asn
Enter fullscreen mode Exit fullscreen mode

The useful one: is my VPN actually working?

This is the endpoint I reach for most. It tells you whether your current IP looks like a normal residential connection or a datacenter / VPN / proxy:

curl hackmyip.com/proxy
Enter fullscreen mode Exit fullscreen mode
proxy: yes
type:  datacenter/hosting
network: AS212238  Datacamp Limited
signal: IP is on a known datacenter/hosting ASN
Enter fullscreen mode Exit fullscreen mode

Why this is handy: turn your VPN on, then run curl hackmyip.com/proxy. If it still shows your real residential ISP and ASN, your VPN is not actually routing that traffic (a leak). If it shows a datacenter ASN like above, the VPN is doing its job. It is a one-second sanity check you can even drop into a script before doing anything sensitive.

The rest of the toolkit

curl hackmyip.com/asn       # your ASN + ISP
curl hackmyip.com/headers   # the request headers the server sees
curl hackmyip.com/ua        # your User-Agent
curl hackmyip.com/rdns      # reverse DNS (PTR) of your IP
curl hackmyip.com/help      # the full menu
Enter fullscreen mode Exit fullscreen mode

All of it is free, keyless, and runs on Cloudflare's edge, so it is fast from anywhere. If you would rather hit a full JSON API (DNS, WHOIS, blacklist, breach checks, and more), the no-key API is documented at https://hackmyip.com/api-docs.

What do you use for this in your scripts? Curious whether people are still hardcoding ifconfig.me or have a sharper trick.

Top comments (0)