Skip to content

Instantly share code, notes, and snippets.

@ipoddubny
Last active April 15, 2023 23:22
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ipoddubny/27111c83c3a2870a55e1 to your computer and use it in GitHub Desktop.
Save ipoddubny/27111c83c3a2870a55e1 to your computer and use it in GitHub Desktop.
How to get public IP address from Linux shell

http

curl ifconfig.co
curl icanhazip.com
curl ifconfig.me
curl http://smart-ip.net/myip

telnet

telnet myip.gelma.net

dns

dig +short @resolver1.opendns.com myip.opendns.com
dig +short @ns1.google.com -t txt o-o.myaddr.l.google.com
@leiless
Copy link

leiless commented Jun 24, 2021

curl -4vL https://myip.country/ip
curl -vL https://ipv4.icanhazip.com
curl -vL https://ipv6.icanhazip.com
curl -4vL https://checkip.amazonaws.com

@jpluimers
Copy link

Note that myip.gelma.net does not resolve any more, so the telnet trick now fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment