I, traditionally, always had an alias/function for easy access to my WAN IP from the CLI:
$ type -a whatismyip
whatismyip is a function
whatismyip ()
{
curl ipv4.icanhazip.com
}
This alias was created many years ago, possibly using a different domain, but always using HTTP.
Recently I discovered that more and more frequently referenced one-liner, which finds the same information through DNS.
But is it really the same?
While writing this, I am using 4G tethering, and the results differ between protocols.
Even more surprising, they differ also between DNS servers.
And funnily, ns1.google.com
, has different results from 8.8.8.8
.
$ whatismyip
92.251.255.11
$ dig +short myip.opendns.com @resolver1.opendns.com
178.167.254.133
$ dig TXT +short o-o.myaddr.l.google.com @8.8.8.8
"74.125.73.77"
"edns0-client-subnet 178.167.255.120/32"
$ dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
"178.167.255.120"
$ ifconfig | grep 'inet addr:'
inet addr:127.0.0.1 Mask:255.0.0.0
inet addr:192.168.42.125 Bcast:192.168.42.255 Mask:255.255.255.0
inet addr:10.47.206.109 Bcast:10.63.255.255 Mask:255.192.0.0
Anyone having the spirit of explaining this in some detail ? :)
~~EDIT: Just to clarify, I tried all of the above commands in some extent, and they provide consistent results.~~
~~EDIT2: I originally forgot to post the whatismyip
results, but none of the DNS queries matched the HTTP one. I'm trying to reproduce it, unsuccessfully, yet. I have to go back to that Café :)~~
EDIT3: I went back there and got new data. Consistent as last time !