title: Getting the WAN IP: difference between HTTP and DNS
body: <p>I, traditionally, always had an alias/function for easy access to my WAN IP from the CLI:</p>
  
  <pre><code>$ type -a whatismyip 
  whatismyip is a function
  whatismyip () 
  { 
      curl ipv4.icanhazip.com
  }
  </code></pre>
  
  <p>This alias was created many years ago, possibly using a different domain, but always using HTTP.</p>
  
  <p>Recently I discovered that more and more frequently referenced one-liner, which finds the same information through DNS.</p>
  
  <p><strong>But is it really the same?</strong></p>
  
  <p>While writing this, I am using 4G tethering, and the results differ between protocols.</p>
  
  <p>Even more surprising, they differ also between DNS servers.</p>
  
  <p>And funnily, <code>ns1.google.com</code>, has different results from <code>8.8.8.8</code>.</p>
  
  <pre><code>$ 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
  </code></pre>
  
  <p>Anyone having the spirit of explaining this in <em>some</em> detail ? :)</p>
  
  <p>~~<strong>EDIT</strong>: Just to clarify, I tried all of the above commands in some extent, and they provide consistent results.~~</p>
  
  <p>~~<strong>EDIT2</strong>: I originally forgot to post the <code>whatismyip</code> 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é :)~~</p>
  
  <p><strong>EDIT3</strong>: I went back there and got new data. Consistent as last time !</p>