R.I.P. nslookup – Start using dig or host

I have been using nslookup for the longest time I can remember. Although, this may be an older topic to some, it may be a newer topic to most Windows users.

Dear Windows users,

nslookup has been deprecated.

The organization that maintains the code for nslookup, Internet Systems Consortium (ISC), has very clearly stated it in the most recent version of nslookup (included with BIND 9), the following message appears:

ISC is the organization behind the Berkeley Internet Name Daemon (BIND). BIND is the most widely used DNS server in the world. nslookup is distributed with BIND.

If you run OS X or any current version of Linux “dig/ host” already installed.

dig

Dig (domain information groper) is a tool that is used for querying DNS servers for various DNS records, making it very useful for troubleshooting DNS problems.

For example, if we enter:

we got the following output:

There is a lot of information in the above output, but we can break each section down to get a better understanding of what we’re looking at. First, we are presented with the version and global options section:

This is followed by a section that gives us more in-depth technical information about the response, or answer:

Then we have a section that repeats our question back to us. This basically serves as a reminder of exactly what we told dig we want to look up:

The answer section is probably the section we’re most interested in. This section is where we find the IP addresses that correspond to where we pointed dig:

In our test case, we now know can see that www.google.com resolves to 172.217.9.196.

Finally, the last section shows us some more general statistics about the query. We have the amount of time the query takes, the address the query came from (our router IP), the time the query was placed, and the amount of data that was returned to us:

This example is a very basic example of a common lookup. More advanced lookups can be performed using dig, and therein lies its power. If we type in:

host

The host command is much like dig, but more succinct. If we enter:

host is also capable of running reverse lookups. You can provide it with an IP address, and it will tell you the name of the specific server associated with that IP. For example:

Try typing in host -a, followed by a website address, and note the results. Yes, that’s right. If you type in host -a it gives you the same exact output that you would get from a plain-old dig command with no options set.

Hopefully that quickly explains how dig/host is being used as a nslookup replacement. dig is a whole lot more informative and easy to use.  See the top 12 commands used in dig here.

Installing dig for

Windows:

  1. First go to http://www.isc.org/downloads and look for BIND, click on download button.
  2. and choose right version, for my windows I’m downloading win – 64bit version
  3. When we have successfully downloaded the archive file, extract the zipfile content to a temporary directory on your workstation.
  4. Go into this directory and run as Administrator “BINDInstall.exe”, then choose the “Tools only” option and target directory where to install dig, I had choosen C:\Program Files\dig
  5. Next add the path of the dig folder (C:\Program Files\dig\bin) to the system PATHS variable. We should this way:Within win 10/server2012R2/server2016 search box type environment variables
    Then choose “Edit the system environment variable” and type admin password if needed. Following box will open. There is a button Environment Variables, click on it and
    add the path


    Close all dialogs.

  6. Now we should be able to run dig tool directly from the command line typing dig
  7. Depending on your system you may get an error dialog will open saying MSVCR110.dll is missing.
    Fix: Within this step the dig tools should already work. MS Visual C++ redistribution should be already installed, if not…follow next steps
    the dll is:

    MSVCR110.dll is the Microsoft Visual C++ Redistributable dll that is needed for projects built with Visual Studio 2011. The dll letters spell this out. MS = Microsoft, V = Visual, C = C++, R = Redistributable. For Winroy to get started, this file is probably needed. This error appears when you wish to run a software which require the Microsoft Visual C++ Redistributable 2012. The redistributable can easily be downloaded on the Microsoft website as x86 or x64 edition. Depending on the software you wish to install you need to install either the 32 bit or the 64 bit version. Refer the following link:         Visual C++ Redistributable for Visual Studio 2012 Update 4          https://www.microsoft.com/en-us/download/details.aspx?id=30679

    so download mentioned update and install it.

    Download and installing Visual Studio 2015 from the link: https://www.microsoft.com/en-us/download/details.aspx?id=48145 did not work )
  8. Download & Install:
  9. Depending on the system it may require a restart. I would go ahead and restart.
  10. Now it works!

Linux/ Mac:

In CentOS/RHEL/Fedora dig is part of the ‘bind-utils’ package

CentOS/RHEL/Fedora

For Debian/Ubuntu based distributions it comes from the ‘dnsutils’ package.

Debian/Ubuntu

MacOS X

Dig is included in most Linux and Mac OS X installations by default via the Terminal.