There are a number of ways to figure out your current public IP address automatically, which can be extremely useful for Dynamic DNS (DDNS) situations or other automation ventures, here are some of them.
OpenDNS
dig +short @resolver1.opendns.com ANY myip.opendns.com
If the above doesn’t work, you may want to try this:
dig +short myip.opendns.com @resolver1.opendns.com
ifconfig.co
curl https://ifconfig.co
Akamai
curl http://whatismyip.akamai.com/
Cloudflare
dig @1.1.1.1 ch txt whoami.cloudflare +short
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com