Install dig On Windows 7, Get dig Working On Windows 7 64-Bit OS

I have been wanting to get the use of dig on Windows 7 for awhile but hadn’t taken the time to do so until now. The problem is nslookup is not as helpful in terms of TTL of zone files, etc. and while you can accomplish your tasks with nslookup using dig makes life much easier on Windows 7 when troubleshooting DNS type issues. The other night I was in the middle of a time critical launch of a new web cluster and needed dig on the Windows 7 laptop I was working on so I decided to get it working while I was waiting for some data to transfer. I actually had slipped on setting the TTL, which was for a single sub domain that was part of the transfer, from a TTL of a entire day (86400 seconds) to a TTL of one hour (3600 seconds). Anyhow below is more information on installing dig on a Windows 7 computer.

Detailed DNS Information Provided By nslookup On Windows 7:

The below output shows detailed DNS information using nslookup on a Windows 7 computer after setting d2 or exhaustive debugging information.

C:>nslookup
Default Server:  pfsense.local
Address:  192.168.1.1

> set d2
> louisville.edu
Server:  pfsense.local
Address:  192.168.1.1

------------
SendRequest(), len 38
    HEADER:
        opcode = QUERY, id = 2, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        louisville.edu.local, type = A, class = IN

------------
------------
Got answer (38 bytes):
    HEADER:
        opcode = QUERY, id = 2, rcode = NXDOMAIN
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        louisville.edu.local, type = A, class = IN

------------
------------
SendRequest(), len 38
    HEADER:
        opcode = QUERY, id = 3, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        louisville.edu.local, type = AAAA, class = IN

------------
DNS request timed out.
    timeout was 2 seconds.
timeout (2 secs)
SendRequest failed
------------
SendRequest(), len 32
    HEADER:
        opcode = QUERY, id = 4, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        louisville.edu, type = A, class = IN

------------
------------
Got answer (48 bytes):
    HEADER:
        opcode = QUERY, id = 4, rcode = NOERROR
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 1,  authority records = 0,  additional = 0

    QUESTIONS:
        louisville.edu, type = A, class = IN
    ANSWERS:
    ->  louisville.edu
        type = A, class = IN, dlen = 4
        internet address = 136.165.238.241
        ttl = 814 (13 mins 34 secs)

------------
Non-authoritative answer:
------------
SendRequest(), len 32
    HEADER:
        opcode = QUERY, id = 5, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        louisville.edu, type = AAAA, class = IN

------------
------------
Got answer (32 bytes):
    HEADER:
        opcode = QUERY, id = 5, rcode = NOERROR
        header flags:  response, want recursion, recursion avail.
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        louisville.edu, type = AAAA, class = IN

------------
Name:    louisville.edu
Address:  136.165.238.241

>

Notice how the TTL information provided is in regards to the time left before the local DNS cache queries the root DNS servers again and not the TTL set for the domain. The TTL could have been refreshed a day ago, a week ago, or an hour ago so all we can verify is when a specific domains local DNS cache will update. So while you can find out the necessary DNS information using nslookup if we install dig then we can actually see what the domains TTL is set to as well as when the local DNS cache will expire or when the DNS cache will refresh much more easily.

Install dig On Windows 7:

The information below came from Nicholas Fong’s page but I wanted to expand on the instructions a bit as well as provide the example above as to why dig is much more powerful than nslookup.

  1. Download Dig Files: Click here to download the file necessary to install dig on Windows 7. The file downloaded will be called dig-files3.zip.
  2. Unzip Dig Files: Now unzip the contents of dig-files3.zip to the root of your main drive which will ypically be the C: drive. You can first create the directory which you should simply call “dig” so the new directory path will be “C:\dig” and then unpack all of the files from dig-files3.zip into C:\dig. The package includes cygwin1.dll, dig.exe, host.exe, libbind9.dll, libdns.dll, libeay32.dll, libisc.dll, libisccfg.dll, liblwres.dll, msvcr70.dll, resolv.conf, sha1sum.exe, and whois.exe.
  3. Move msvcr70.dll: Now copy the msvcr70.dll to “%systemroot%\system32\” which typically is the “C:\WINDOWS\system32\” directory. If the file already exists you do not need to copy it from the dig folder to the system32 folder.
  4. Copy resolv.conf To etc: Copy the resolv.conf file located in “C:\dig” to “%systemroot%\system32\drivers\etc” which is typically the same as “C:\WINDOWS\system32\drivers\etc”.
  5. Test Dig: Now open a new Command Prompt window and test dig on your Windows 7 computer. If you simply type “dig.exe” to see if it is working you should get output similar to the below.
    C:dig>dig.exe
    
    ; <<>> DiG 9.3.2 <<>>
    ;; global options:  printcmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 875
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;.                              IN      NS
    
    ;; ANSWER SECTION:
    .                       515760  IN      NS      f.root-servers.net.
    .                       515760  IN      NS      i.root-servers.net.
    .                       515760  IN      NS      c.root-servers.net.
    .                       515760  IN      NS      m.root-servers.net.
    .                       515760  IN      NS      e.root-servers.net.
    .                       515760  IN      NS      d.root-servers.net.
    .                       515760  IN      NS      b.root-servers.net.
    .                       515760  IN      NS      k.root-servers.net.
    .                       515760  IN      NS      l.root-servers.net.
    .                       515760  IN      NS      g.root-servers.net.
    .                       515760  IN      NS      h.root-servers.net.
    .                       515760  IN      NS      j.root-servers.net.
    .                       515760  IN      NS      a.root-servers.net.
    
    ;; Query time: 25 msec
    ;; SERVER: 192.168.1.1#53(192.168.1.1)
    ;; WHEN: Tue Dec 28 12:39:46 2010
    ;; MSG SIZE  rcvd: 228
    
    C:dig>
    
  6. Add Dig To Path: To make the use of dig convenient you should now add “C:\dig” to the primary users path which can be done by first opening Control Panel. Once the Windows 7 Control Panel is open click on User Accounts to display a window similar to the below example image.

    Windows 7 User Accounts

    Once the User Accounts screen is open click on “Change my environment variables” in the left navigation which will open the below window.

    Windows 7 User Account Environment Variables

    In the second section of the Environment Variables configuration window scroll down until you see Path and double click on it to open the below Edit System Variable window. In this case the System Variable we are editing is the Path.

    Windows 7 Edit System Variable Path

    In the example image above you can see that “;C:\dig” has been added to the end of the Variable Value field. Click the OK button to save the settings and then close all other open configuration windows including the Windows 7 Control Panel. Now if you open a new Command Prompt window you should be able to type “dig” and receive the output noted in step five.

  7. Example Windows 7 Dig Output: First we will use whois to locate the NS servers associated with the domains we want to locate information about as shown below.
    C:>whois louisville.edu
    
    This Registry database contains ONLY .EDU domains.
    The data in the EDUCAUSE Whois database is provided
    by EDUCAUSE for information purposes in order to
    assist in the process of obtaining information about
    or related to .edu domain registration records.
    
    The EDUCAUSE Whois database is authoritative for the
    .EDU domain.
    
    A Web interface for the .EDU EDUCAUSE Whois Server is
    available at: http://whois.educause.net
    
    By submitting a Whois query, you agree that this information
    will not be used to allow, enable, or otherwise support
    the transmission of unsolicited commercial advertising or
    solicitations via e-mail.  The use of electronic processes to
    harvest information from this server is generally prohibited
    except as reasonably necessary to register or modify .edu
    domain names.
    
    You may use "%" as a wildcard in your search. For further
    information regarding the use of this WHOIS server, please
    type: help
    
    --------------------------
    
    Domain Name: LOUISVILLE.EDU
    
    Registrant:
       University of Louisville
       Information Technology - Communications Services
       109 Miller Info Tech Center
       Louisville, KY 40292
       UNITED STATES
    
    Administrative Contact:
       Domain Admin
       University of Louisville
       109 Miller Info Tech Center
       Information Technology Communications Services
       Louisville, KY 40292
       UNITED STATES
       (502) 852-1776
       domain.admin@hermes.louisville.edu
    
    Technical Contact:
       Domain Tech
       University of Louisville
       109 Miller Info Tech Center
       Information Technology Communications Services
       Louisville, KY 40292
       UNITED STATES
       (502) 852-1776
       domain.tech@hermes.louisville.edu
    
    Name Servers:
       HERMES.LOUISVILLE.EDU           136.165.253.10
       PAN.LOUISVILLE.EDU              136.165.253.89
       HERMES.IPV6.LOUISVILLE.EDU      2610:1e0:1800:f1::1
       PAN.IPV6.LOUISVILLE.EDU         2610:1e0:1800:af1::1
       MIDNIGHT.STATE.KY.US
    
    Domain record activated:    11-Sep-1989
    Domain record last updated: 17-Feb-2009
    Domain expires:             31-Jul-2011
    

    After locating the DNS servers we will use dig to find out the actual TTL configured for a specific domain as shown below.

    C:>dig @HERMES.LOUISVILLE.EDU louisville.edu
    
    ; <<>> DiG 9.3.2 <<>> @HERMES.LOUISVILLE.EDU louisville.edu
    ; (1 server found)
    ;; global options:  printcmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2023
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 5, ADDITIONAL: 6
    
    ;; QUESTION SECTION:
    ;louisville.edu.                        IN      A
    
    ;; ANSWER SECTION:
    louisville.edu.         3600    IN      A       136.165.238.241
    
    ;; AUTHORITY SECTION:
    louisville.edu.         3600    IN      NS      hermes.ipv6.louisville.edu.
    louisville.edu.         3600    IN      NS      midnight.state.ky.us.
    louisville.edu.         3600    IN      NS      pan.ipv6.louisville.edu.
    louisville.edu.         3600    IN      NS      hermes.louisville.edu.
    louisville.edu.         3600    IN      NS      pan.louisville.edu.
    
    ;; ADDITIONAL SECTION:
    hermes.louisville.edu.  3600    IN      A       136.165.253.10
    pan.louisville.edu.     3600    IN      A       136.165.253.89
    hermes.ipv6.louisville.edu. 3600 IN     A       136.165.253.10
    hermes.ipv6.louisville.edu. 3600 IN     AAAA    2610:1e0:1800:f1::1
    pan.ipv6.louisville.edu. 3600   IN      A       136.165.253.89
    pan.ipv6.louisville.edu. 3600   IN      AAAA    2610:1e0:1800:af1::1
    
    ;; Query time: 33 msec
    ;; SERVER: 136.165.253.10#53(136.165.253.10)
    ;; WHEN: Tue Dec 28 12:54:21 2010
    ;; MSG SIZE  rcvd: 285
    
    C:>
    

    As you can see above the TTL for the louisville.edu domain is 3600 seconds or one hour. So while the same can be done with nslookup by setting the server to the NS server for the domain, which in this case could be hermes.louisville.edu, it is still much easier to use dig.

You now have the functionality of dig on Windows 7 which will make troubleshooting and/or managing DNS much easier for you!

DNS and BIND (5th Edition) (Paperback)

By (author): Cricket Liu, Paul Albitz


List Price: $49.99 USD
New From: $27.25 USD In Stock
Used from: $12.74 USD In Stock

Pro DNS and BIND (Paperback)

By (author): Ron Aitchison


List Price: $44.99 USD
New From: $27.34 USD In Stock
Used from: $6.35 USD In Stock

Share