I’ve so often googled “whats my ip” and today I was curious how to do the same on the cli. Seems that there are some DNS
which return your IP address if you ask them nicely.
The end result is this script, which I now have as
#!/bin/bash # From # https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux/ set -e echo "IPv4: $(dig +short txt ch whoami.cloudflare @188.8.131.52)" echo "IPv6: $(dig TXT +short o-o.myaddr.l.google.com @ns1.google.com)"