Skip to content

Instantly share code, notes, and snippets.

@ipoddubny
Last active November 14, 2024 11:51
Show Gist options
  • 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
@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