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.
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
dig @220.127.116.11 ch txt whoami.cloudflare +short
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com