💾 Archived View for jb.smol.pub › whats-my-ip captured on 2023-07-10 at 13:20:30. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Sometimes you want to find out what public IP address your connection is using to reach the outside world.
An easy way to find this information is to use a DNS query, which I find to be a quicker way (and also a lighter weight query) instead of opening up a website to find this information.
OpenDNS has a service you can query from the command line which will return your IP address.
~$ dig +short myip.opendns.com @resolver1.opendns.com
You can use this version of the query to find the public IPv6 address that your connection is using.
~$ dig +short aaaa myip.opendns.com @resolver1.opendns.com
I've added this alias to my .zprofile in zsh so I simply have to type myip in the terminal on _macOS_ to run the full command.
alias myip="dig +short myip.opendns.com @resolver1.opendns.com"
There are a few alternatives to the OpenDNS query service.
Both Google ...
~$ dig @ns1.google.com TXT o-o.myaddr.l.google.com +short
and Akamai ....
~$ dig @ns1-1.akamaitech.net ANY whoami.akamai.net +short
... both offer similar DNS lookup services. You can add them to your bash or zsh profile similar to the example above.
© JB