Skip to content

Instantly share code, notes, and snippets.

@sylvaincombes
Last active November 2, 2025 22:54
Show Gist options
  • Select an option

  • Save sylvaincombes/b9cfd90ba47655048a6f to your computer and use it in GitHub Desktop.

Select an option

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

@ofthenorth
Copy link

curl ipget.io
curl -4 ipget.io
curl -6 ipget.io

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