This article describes how to use the dig and nslookup tools to test DNS settings. (Microsoft Windows uses nslookup, while Mac OS X and Linux use dig.) You can use these tools to determine the IP address associated with a domain name, obtain the mail server settings for a domain, and much more.
You can use web-based tools or command-line tools to run these types of tests.
If you have never worked at the command line before, web-based network tools provide an easy way to start troubleshooting DNS. There are many web sites that provide these services for free.
For example, to test if DNS propagation is complete, you can visit http://www.whatsmydns.net and specify a domain name. The site displays a global map showing the IP address associated with the domain name for a variety of DNS servers around the world.
For more in-depth DNS testing, you can use the online dig interface at http://www.digwebinterface.com. For example, to view the A record for a domain (and determine the IP address associated with the domain), follow these steps:
Dig (on Mac OS X and Linux) and nslookup (on Microsoft Windows) are the primary command-line tools for troubleshooting DNS issues.
While web-based tools are convenient and easy to use, it is often faster to use a command-line tool on your own system. The exact steps to do this depend on your computer's operating system. Follow the appropriate procedures below for your operating system.
Microsoft Windows does not include the dig program. However, the nslookup program provides much of the same functionality. To run nslookup on Microsoft Windows, follow these steps:
nslookup example.com 126.96.36.199
By default, nslookup looks up the A record for a domain. To look up a different DNS record, you must enter interactive mode. For example, to view the MX (mail exchanger) records for the example.com domain, type nslookup at the command line. At the > nslookup prompt, type the following commands:
set type=MX example.com
Interpret the output from nslookup. For example, the following output shows information for example.com:
Server: resolver1.opendns.com Address: 188.8.131.52 Name: example.com Address: 184.108.40.206
From this, we can see that example.com is currently pointing to IP address 220.127.116.11. We can also see that DNS server resolver1.opendns.com was used for the query.
To run the dig program on Mac OS X and Linux, follow these steps:
At the command prompt, type the following command. Replace example.com with the domain that you want to test:
dig @18.104.22.168 example.com
By default, dig displays the A record for a domain. To look up a different DNS record, add it to the end of the command. For example, to look up the MX (mail exchanger) record for the example.com domain, type the following command:
dig example.com MX
Interpret the output from dig. For example, the following output shows the dig information for example.com:
[email protected]:~$ dig example.com ; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> example.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46803 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 2424 IN A 22.214.171.124 ;; Query time: 12 msec ;; SERVER: 192.168.0.1#53(192.168.0.1) ;; WHEN: Thu Jan 9 16:07:09 2014 ;; MSG SIZE rcvd: 45
Dig displays a QUESTION SECTION (the request) and an ANSWER SECTION (what the DNS server sends in response to the request). In this case, we used the default options for dig, which simply looks up the A record for a domain. From this, we can see that example.com currently points to IP address 126.96.36.199.