How does dig find my WAN-IP-address? What is "myip.opendns.com" doing?

First to summarize the general usage of dig: it requests the IP assigned to the given domain from the default DNS server. So e.g. dig google.de would request the IP assigned to the domain google.de. That would be 172.217.19.99.

The command you mentioned is:

dig +short myip.opendns.com @resolver1.opendns.com

So what this command does is: it sends a request for the IP of the domain myip.opendns.com to the DNS server resolver1.opendns.com. This server is programmed that, if this special domain is requested, the IP the request comes from is sent back.

The reasons why the method of querying the WAN IP using DNS is better were mentioned by krinkle: standardised, more stable and faster.

The reason I could imagine for those two IPs is that your router caches DNS requests and returns an old IP.

Another problem could be DualStack Lite. That is often used by new internet contracts. Do you know whether your ISP is using DS Lite?


This free service has been shut down by Cisco. Payed it might still work.

Google provides the same service.

ipv4

dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com

or ipv6

dig -6 TXT +short o-o.myaddr.l.google.com @ns1.google.com

Tags:

Dns

Dig

Dyndns