Skip to content

Instantly share code, notes, and snippets.

@rkalkani
Last active April 11, 2025 12:56
Show Gist options
  • Save rkalkani/7428a8769f7cc6710c58680938dc5833 to your computer and use it in GitHub Desktop.
Save rkalkani/7428a8769f7cc6710c58680938dc5833 to your computer and use it in GitHub Desktop.
Get public IP address used by your machine to connect to the internet

Get Public IP

DNS

Google

dig o-o.myaddr.l.google.com txt @ns1.google.com +short
# OR
nslookup -type=txt o-o.myaddr.l.google.com ns1.google.com

Cloudflare

dig whoami.cloudflare ch txt @1.1.1.1 +short

Akamai

dig whoami.akamai.net. @ns1-1.akamaitech.net. +short
# OR
nslookup whoami.akamai.net. ns1-1.akamaitech.net

OpenDNS

dig myip.opendns.com @dns.opendns.com
# OR
nslookup myip.opendns.com. dns.opendns.com

HTTP

curl ipinfo.io
curl ifconfig.co
curl icanhazip.com
curl ifconfig.me
curl checkip.dyndns.org
@rkalkani
Copy link
Author

rkalkani commented Apr 2, 2025

The correct value for OpenDNS is:

dig myip.opendns.com @dns.opendns.com
# OR
nslookup myip.opendns.com. dns.opendns.com

It is indeed, Thanks for update. Corrected in gist.

@who0ps
Copy link

who0ps commented Apr 11, 2025

ip + hostname + provider + location.
IPv4: curl 2ip.ua
IPv6: curl -6 2ip.com.ua

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