Skip to content

Instantly share code, notes, and snippets.

@scmrus
Forked from rkalkani/get-public-ip.md
Created December 2, 2022 16:22
Show Gist options
  • Save scmrus/5dc1d3f475652020a8bf7a698173ab2b to your computer and use it in GitHub Desktop.
Save scmrus/5dc1d3f475652020a8bf7a698173ab2b 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