How to troubleshoot DNS with dig and nslookup

Last modified: January 17, 2025
You are here:
Estimated reading time: 3 min
This article outlines the use of the dig and nslookup tools to test and verify DNS settings. On Microsoft Windows, the preferred tool is nslookup, while dig is commonly used on Mac OS X and Linux systems. These tools help identify the IP address of a domain, retrieve mail server settings, and perform other DNS-related tasks.

Both web-based utilities and command-line tools can be used to conduct these tests.

Troubleshooting DNS with web-based tools

If you’re unfamiliar with the command line, web-based tools are a simple way to start troubleshooting DNS issues. Numerous free websites offer these services.

For instance, to check if DNS propagation is complete, you can visit WhatsMyDNS.net. Enter a domain name, and the site will show a global map with the IP address associated with the domain across various DNS servers worldwide.

For more advanced DNS testing, you can use the online dig interface at DigWebInterface. To view the A record of a domain (which reveals its associated IP address), follow these steps:

  1. Go to DigWebInterface.
  2. In the “Hostnames or IP addresses” text box, type the domain you want to test.
  3. In the “Type” drop-down menu, select “A” (you can also test other DNS record types like MX and CNAME).
  4. Under “Options,” check the box for “Show command.”
  5. Under “Nameservers,” select the DNS server you want to use for the query (you can stick with the default or use a specific DNS server like OpenDNS or Google).
  6. Click Dig. The results will display the output from the dig command, including the domain name and its associated IP address if an A record is configured.

Troubleshooting DNS with command-line tools

Dig (on macOS and Linux) and nslookup (on Microsoft Windows) are the primary command-line tools for troubleshooting DNS issues. While web-based tools are convenient, using a command-line tool directly on your system is often faster and more efficient.

Using nslookup on Microsoft Windows

To run nslookup on Microsoft Windows, follow these steps:

  1. Open the Command Prompt: First, click on Start, then choose Run. In the Run dialog box, type cmd and press Enter. This will open the Command Prompt window.

  2. Run the nslookup Command: In the Command Prompt, type the following command, replacing example.com with the domain name you want to query:
    nslookup example.com
    Press Enter after typing the command.

  3. Use a Specific DNS Server (Optional): If you want to use a specific DNS server to perform the lookup, you can specify the server’s IP address or hostname. For example:
    nslookup example.com 208.67.222.222
    This command will query example.com using the OpenDNS server with the IP address 208.67.222.222.

  4. Enter Interactive Mode: To enter interactive mode, simply type nslookup at the command prompt and press Enter. Once you see the > prompt, you can enter additional commands. For instance, to query the MX records for example.com, type:
    set type=MX
    example.com

Server: This shows the DNS server that was used to perform the query (in this case, OpenDNS).

Address: The IP address of the DNS server used for the query.

Name: The domain name that was queried (e.g., example.com).

Address: The IP address associated with the domain (e.g., 93.184.216.119).

Using dig on Apple Mac OS X and Linux

To run the dig program on Mac OS X and Linux, follow these steps:
  1. Open a terminal window.
    On Mac OS X, go to Applications > Utilities, and click Terminal.
    On Linux, simply open a terminal window.

  2. Run the dig command.
    At the command prompt, type the following command, replacing example.com with the domain you want to test:

    dig example.com

    To use a specific DNS server for the query, you can use the @ option. For example, to query using an OpenDNS server with IP address 208.67.222.222, use this command:

    dig @208.67.222.222 example.com

    By default, dig will display the A record (IP address) for a domain. If you want to look up different DNS records, simply add the record type to the command. For example, to look up the MX (mail exchanger) records for example.com, type:

    dig example.com MX

  3. Interpret the output.
    After running the command, you’ll see a detailed output. Here’s an example of what the results might look like when querying for example.com:

user@localhost:~$ 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 93.184.216.119
;; 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

In this output:
  • QUESTION SECTION shows the DNS query (what you asked for).
  • ANSWER SECTION gives the response from the DNS server, showing that example.com points to the IP address 93.184.216.119.
  • The SERVER field shows the DNS server used for the query.

From the output, you can confirm the IP address of the domain and troubleshoot any DNS-related issues.

Was this article helpful?
Dislike 0
Views: 16

Braw Hosting Sales

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.

Scroll to Top