This question: "How can I get my external IP address in bash?"
Solves the question with a call to dig:
dig +short myip.opendns.com @resolver1.opendns.com;
that is the fastest resolution possible, as it involves a single udp packet.
However, that is only one site: OpenDNS, Is there any alternative?
And, makes use of dig, that is not available by default. Again, Is there an alternative?
Note: I needed to solve this problem as the OpenDNS service didn't work locally due to a (also local) redirect of port 53. I finally found out the reason (I had forgotten about the redirect). First, by using this command to find if dnssec is working (locally missing
dig pir.org +dnssec +multi
And also using this command to find out if your ISP is redirecting OpenDNS resolutions:
host -t txt which.opendns.com 184.108.40.206
If being redirected, you will get an answer of:
"I am not an OpenDNS resolver."