Knowledge Base

Troubleshooting DNS with dig and nslookup

In this article, we will explain how to use the dig and nslookup tools to test your DNS settings. These tools are specific depending on the operating system you are using. Specifically, if you are running MacOS or Linux, you’ll use dig. If you are on a Windows device you will make use of nslookup.

Using these tools, you will be able to determine what the IP address associated with a domain name is, obtain information such as the mail server settings for a domain, and so much more.

Troubleshooting DNS with Command-line tools

There are two primary command-line based tools for troubleshooting DNS issues and those are specific to operating systems. Dig (on MacOS and Linux) and nslookup (for Microsoft Windows users).

While there are web tools you can use to perform the same actions, command-line is often faster and is a tool built into your own system. To get started, follow the guides below specific to your operating system.

Using nslookup on Windows devices

Dig does not come native to Microsoft Windows but thankfully, there is another just as powerful system called nslookup. To get started with nslookup, follow the steps outlined below:

  • Open a new command line window by clicking on the Start button and searching for command line (or cmd).
  • In the command line interface, type the following command replacing example.com with the domain name you would like to test: nslookup example.com
  • You should now see an output for your nslookup command. In our case we can see example.com resolves to the IP address: 93.184.216.34
Name: example.com
Address: 93.184.216.34

By default nslookup will lookup the A record of a domain name. You can change this by entering the interactive mode of nslookup. For example, to view an MX record on the domain example.com type nslookup in the command line.

At the > in the command prompt type in the following commands:
set type=MX
example.com

And that is it! You have successfully ran an nslookup on your Windows device.

Using dig on MacOS / Linux devices

Dig is the MacOS / Linux alternative to Window’s nslookup. To get started with dig follow the instructions below:

  • Open a new Terminal window. This process can differ depending on your specific operating system though they should be fairly similar to the steps below:
    • MacOS: Click Applications -> Utilities -> Terminal
  • In your terminal window, type in the following command replacing example.com with your own domain: dig example.com
  • You should see the output of the dig command in your terminal like below:
hostdash@HostDash-MacBook ~ % dig example.com

; <<>> DiG 9.10.6 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34932
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;example.com.			IN	A

;; ANSWER SECTION:
example.com.		20346	IN	A	93.184.216.34

;; Query time: 15 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu Jun 17 20:18:31 EEST 2021
;; MSG SIZE rcvd: 56

Dig uses a question and answer form in the output. In our case, we can see the question is to gather the A record for example.com and the answer shows example.com’s A record being 93.184.216.34.

By default dig will lookup the A record for a domain name. If you would like to output a different DNS record you can add it to the end of the command.

For example, to find the MX record for example.com you would want to run the command: dig example.com MX

Browser alternatives to testing DNS with dig and nslookup

It is worth mentioning there are alternative solutions (specifically browser based networking tools) if you are not familiar with command line. These free online services typically cater to specific pieces of information.

For example, if your goal is to determine if DNS propagation has completed, you can use the free online service called https://whatsmydns.com and enter your websites domain name. This specific service will then output the IP addresses associated with your domain name from various DNS servers located across the globe.

If you are after a more in-depth overview on a domains DNS, you can use the online dig interface located at https://digwebinterface.com. To use the dig web interface to determine the IP address associated with a domain name follow the steps below:

  • Using your preferred web browser, navigate to dig web interface website
  • In the large text box called Hostnames or IP Addresses enter the domain name of the website you would like to test
  • In the Type drop down menu list, select the DNS record type A

You can test multiple websites at once, as well as different DNS record types though for this article, we will focus on a single domain name and the A DNS record. For more information on DNS record types click here.

  • Under Options, select the Show command checkbox
  • If you wish to test from a specific DNS server (such as OpenDNS or Google DNS) select it from the Nameservers dropdown menu. Alternatively, and for simplicity, you can leave it set to the default option.
  • Once ready, click on the dig button to start the process. Once you click the button, you will be presented with the results from the dig as well as the full command used to initiate the process.

Did you find this article helpful?

If you found this article helpful then you will love our support! Get blazing fast Shared Hosting and experience the HostDash difference today!

Check out our Shared Hosting plans today.


Have a Question?
We're here to help!

Email Us

Send us an email with your questions and we'll get back to you momentarily.

Send us an Email
Live Chat

Chat live with a member of our sales team to discuss your next project.

Chat with Sales
Submit a Ticket

Chat live with a member of our sales team to discuss your next project.

Submit a ticket