dig command (Domain Information Groper) is a popular Linux utility used for performing DNS lookups. It provides more flexibility than Windows NSLookup but, unfortunately, it isn't available in Windows 10 by default.
One option for using
dig on Windows is to install BIND. This tool lets you use the
dig command in the Windows command prompt.
In this tutorial, we will show you how to install BIND and edit Windows environment variables to enable dig. We also provide examples of using the
dig command to perform a DNS lookup.
- A system running Windows 10.
- An account with administrator privileges.
- Access to the command prompt.
1. Visit the BIND download page using your preferred web browser.
2. Click the Download button to select the latest stable version of BIND. In this tutorial, we are using version 9.16.23.
3. Click the link to download the BIND installation zip file.
1. Extract the BIND installation file.
2. Open the BINDInstall.exe file as an administrator to start the installation wizard.
3. In the Target Directory field, set the path to where you want to install BIND on your system.
4. Set a name for your service account in the Service Account Name field.
5. Set and confirm a password for the service account.
6. In the Options section, check the Tools Only box.
7. Click the Install button to start the installation process.
Note: Installing BIND may automatically install Microsoft Visual C++ Redistributable. In this case, click the Install button to confirm.
8. Once the installation is complete, click OK to confirm and Exit to close the installer.
Create Windows Path Variable
1. Open the Start menu and search for "environment variables".
2. Select the Edit the system environment variables option.
3. In the System Properties window, under the Advanced tab, click the Environment Variables… button.
4. Under System variables, scroll down and select Path, then click the Edit button.
5. In the variable editing window, click New and enter the path to the BIND installation folder (the default path is C:\Program Files\ISC BIND 9\bin).
6. Click OK to confirm the edits to the Path variable.
7. Click OK to confirm the changes and exit the Environment Variables window.
Note: Learn more about setting environment variables in Windows.
Using dig Command in Windows
After installing BIND, open the Windows command prompt to start using the
dig command. The
dig command uses the following syntax:
dig [hostname] [options]
Using dig Without Command Options
dig command without any options returns DNS data on the provided hostname. For instance:
dig command output contains the following sections:
HEADER: Basic information about the request.
OPT PSEUDOSECTION: Advanced information about the request.
QUESTION SECTION: The summary of the query made to the DNS. In this example, it is the first available A record for the hostname provided.
ANSWER SECTION: The answer to the query made to the DNS. In this example, it is the IP address for the first A record.
dig command also allows you to specify the type of record you want to query by using:
dig [hostname] [record type]
Note: The DNS record types you can query include A, AAAA, MX (Mail Exchanger), NS, and TXT. Learn more in our guide to DNS record types.
List All Records for a Hostname
To return all records for the provided hostname, use the
dig [hostname] any
Get a Hostname's IP Address
+short option with the
dig command provides a shortened output (usually just the IP address):
dig [hostname] +short
dig google.com +short
Check DNS Resolution
+trace option resolves the query starting from the root nameserver and working its way down, reporting the results from each step:
dig [hostname] +trace
dig google.com +trace
Query a Nameserver Directly
dig command also allows you to query a nameserver directly:
dig @[nameserver address] [hostname]
Do a Reverse DNS Lookup
Another use for the
dig command is performing reverse DNS lookups:
dig -X [IP address]
Note: Learn more about reverse DNS lookups in our guide to reverse DNS.
After reading this tutorial, you should be able to use the
dig command in the command prompt through BIND.
If you want to use
dig with a Linux system instead, check out our guide to installing dig on CentOS 7 and 8.