Command line
Dig answers terminals too. No key, no sign-up, just plain text back.
Just your IP
curl gopherip.com
Returns your public IP and a newline, nothing else. Same with wget -qO- gopherip.com. If a tool sends browser-like headers, use the always-plain address:
curl gopherip.com/ip
PowerShell (Windows)
(Invoke-RestMethod gopherip.com/ip).Trim()
Everything, as JSON
curl gopherip.com/json
Includes your IP, IP version, type, hostname, network (ISP and AS number), rough location, and the user agent your tool sent. Handy with jq:
curl -s gopherip.com/json | jq -r .isp
Look up another address
curl gopherip.com/ip/8.8.8.8
Command-line tools get JSON. In a browser, add ?format=json.
See your request headers
curl gopherip.com/headers
In a script
MYIP=$(curl -s gopherip.com)
echo "Allowing $MYIP"
Fair use
It's free for everyday scripts and checks. Please don't hit it more than once a minute from the same place; Dig has short legs.