Skip to content

Instantly share code, notes, and snippets.

@sylvaincombes
Last active April 22, 2024 07:08
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sylvaincombes/b9cfd90ba47655048a6f to your computer and use it in GitHub Desktop.
Save sylvaincombes/b9cfd90ba47655048a6f to your computer and use it in GitHub Desktop.
View your external ip from linux / unix shell
# with dig (fastest way)
dig +short myip.opendns.com @resolver1.opendns.com;
# alternative
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}';
######################################################################################################
## Other method with curl / get and 3rd party, this choice is less judicious
######################################################################################################
# with curl
curl ipinfo.io/ip;
# alternatives
curl ifconfig.me;
curl ifconfig.me/all;
curl icanhazip.com;
curl ipecho.net/plain;
curl ifconfig.co;
# with GET
GET ipinfo.io/ip;
# alternatives
GET ifconfig.me;
GET ifconfig.me/all;
GET icanhazip.com
GET ipecho.net/plain
GET ifconfig.co
@kirgizmustafa17
Copy link

curl -4 ifconfig.me # to get ipv4 adress
curl -6 ifconfig.me # to get ipv6 adress

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