Skip to content

Instantly share code, notes, and snippets.

@joshbrand
Forked from rkalkani/get-public-ip.md
Created April 27, 2023 19:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshbrand/df2c21aa5f64e65291e67690db92819d to your computer and use it in GitHub Desktop.
Save joshbrand/df2c21aa5f64e65291e67690db92819d 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 whoami.akamai.net. @ns1-1.akamaitech.net. +short
# OR
nslookup whoami.akamai.net. ns1-1.akamaitech.net

HTTP

curl ipinfo.io
curl ifconfig.co
curl icanhazip.com
curl ifconfig.me
curl checkip.dyndns.org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment