danielhpavey.uk

How to get your public IP address in the terminal

There are few different ways, some may or may not working depending on your specific environment.

dig +short myip.opendns.com @resolver1.opendns.com
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
host myip.opendns.com resolver1.opendns.com
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}'
Date: Tuesday 7th December 2021