How to Check Your Public IP on Linux (curl)
On a headless server you cannot "look at a web page", so you query an echo service that returns the IP it sees.
With curl
curl https://show-ip-addr.com/api/myip # JSON: ip, hostname, country, org
curl ifconfig.me # plain IP
curl -s https://api.ipify.org # plain IP
Extract just the IP from our JSON:
curl -s https://show-ip-addr.com/api/myip | grep -oP '"ip":"\K[^"]+'
With dig (DNS-based, no HTTP)
dig +short myip.opendns.com @resolver1.opendns.com
dig -4 +short txt ch whoami.cloudflare @1.1.1.1
Local vs Public
Remember ip addr shows your private IP, not the public one — see Linux IP commands and how to find my IP.
Force IPv4 or IPv6 with
curl -4/curl -6. In the current deployment/api/myipreturns IPv4 (the server reaches the Internet over IPv4), while/api/ip?q=and the lookup tools accept IPv6 too.