Dig +short myip.opendns.com @resolver1.opendns.com not showing my real public IP

originally posted in https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux/

Hi!

I’ve read the post and tried the command, but I always get 146.112.255.205 (opendns.com) instead of mine.

It is anything I can do to have it working?. I use netalertx which has embedded the command dig +short and I only can change options to that.

I tried to edit my OP but I get a 422 error.
Want to add that I tested my IP with whatismyip.com and other services, and it is now 42.x.x.x

I just tested and it is returning the correct IPv4 for me:

dig +short myip.opendns.com @resolver1.opendns.com
dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
dig +short txt ch whoami.cloudflare @1.0.0.1
## THIS IS FOR IPv6 ##
dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com

Are all commands giving you issues? It is possible that those DNS might be blocked by the ISP or your router. Can you ping those DNS server and make some queries?

ping ns1.google.com
ping resolver1.opendns.com