Find your public IP address from linux command line

Problem

You would like to find out your public IP from the command line without using an online service

Solution

Use dig like the following line (taken from https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux/):

dig +short myip.opendns.com @resolver1.opendns.com

you could also add it as an alias:

alias myip=”dig +short myip.opendns.com @resolver1.opendns.com”