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.

text

  1. C:\>nslookup
  2. Default Server:  pfsense.local
  3. Address:  192.168.1.1
  4.  
  5. > set d2
  6. > louisville.edu
  7. Server:  pfsense.local
  8. Address:  192.168.1.1
  9.  
  10. ------------
  11. SendRequest(), len 38
  12.     HEADER:
  13.         opcode = QUERY, id = 2, rcode = NOERROR
  14.         header flags:  query, want recursion
  15.         questions = 1,  answers = 0,  authority records = 0,  additional = 0
  16.  
  17.     QUESTIONS:
  18.         louisville.edu.local, type = A, class = IN
  19.  
  20. ------------
  21. ------------
  22. Got answer (38 bytes):
  23.     HEADER:
  24.         opcode = QUERY, id = 2, rcode = NXDOMAIN
  25.         header flags:  response, want recursion, recursion avail.
  26.         questions = 1,  answers = 0,  authority records = 0,  additional = 0
  27.  
  28.     QUESTIONS:
  29.         louisville.edu.local, type = A, class = IN
  30.  
  31. ------------
  32. ------------
  33. SendRequest(), len 38
  34.     HEADER:
  35.         opcode = QUERY, id = 3, rcode = NOERROR
  36.         header flags:  query, want recursion
  37.         questions = 1,  answers = 0,  authority records = 0,  additional = 0
  38.  
  39.     QUESTIONS:
  40.         louisville.edu.local, type = AAAA, class = IN
  41.  
  42. ------------
  43. DNS request timed out.
  44.     timeout was 2 seconds.
  45. timeout (2 secs)
  46. SendRequest failed
  47. ------------
  48. SendRequest(), len 32
  49.     HEADER:
  50.         opcode = QUERY, id = 4, rcode = NOERROR
  51.         header flags:  query, want recursion
  52.         questions = 1,  answers = 0,  authority records = 0,  additional = 0
  53.  
  54.     QUESTIONS:
  55.         louisville.edu, type = A, class = IN
  56.  
  57. ------------
  58. ------------
  59. Got answer (48 bytes):
  60.     HEADER:
  61.         opcode = QUERY, id = 4, rcode = NOERROR
  62.         header flags:  response, want recursion, recursion avail.
  63.         questions = 1,  answers = 1,  authority records = 0,  additional = 0
  64.  
  65.     QUESTIONS:
  66.         louisville.edu, type = A, class = IN
  67.     ANSWERS:
  68.     ->  louisville.edu
  69.         type = A, class = IN, dlen = 4
  70.         internet address = 136.165.238.241
  71.         ttl = 814 (13 mins 34 secs)
  72.  
  73. ------------
  74. Non-authoritative answer:
  75. ------------
  76. SendRequest(), len 32
  77.     HEADER:
  78.         opcode = QUERY, id = 5, rcode = NOERROR
  79.         header flags:  query, want recursion
  80.         questions = 1,  answers = 0,  authority records = 0,  additional = 0
  81.  
  82.     QUESTIONS:
  83.         louisville.edu, type = AAAA, class = IN
  84.  
  85. ------------
  86. ------------
  87. Got answer (32 bytes):
  88.     HEADER:
  89.         opcode = QUERY, id = 5, rcode = NOERROR
  90.         header flags:  response, want recursion, recursion avail.
  91.         questions = 1,  answers = 0,  authority records = 0,  additional = 0
  92.  
  93.     QUESTIONS:
  94.         louisville.edu, type = AAAA, class = IN
  95.  
  96. ------------
  97. Name:    louisville.edu
  98. Address:  136.165.238.241
  99.  
  100. >

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.
    text

    1. C:\dig>dig.exe
    2.  
    3. ; <<>> DiG 9.3.2 <<>>
    4. ;; global options:  printcmd
    5. ;; Got answer:
    6. ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 875
    7. ;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 0
    8.  
    9. ;; QUESTION SECTION:
    10. ;.                              IN      NS
    11.  
    12. ;; ANSWER SECTION:
    13. .                       515760  IN      NS      f.root-servers.net.
    14. .                       515760  IN      NS      i.root-servers.net.
    15. .                       515760  IN      NS      c.root-servers.net.
    16. .                       515760  IN      NS      m.root-servers.net.
    17. .                       515760  IN      NS      e.root-servers.net.
    18. .                       515760  IN      NS      d.root-servers.net.
    19. .                       515760  IN      NS      b.root-servers.net.
    20. .                       515760  IN      NS      k.root-servers.net.
    21. .                       515760  IN      NS      l.root-servers.net.
    22. .                       515760  IN      NS      g.root-servers.net.
    23. .                       515760  IN      NS      h.root-servers.net.
    24. .                       515760  IN      NS      j.root-servers.net.
    25. .                       515760  IN      NS      a.root-servers.net.
    26.  
    27. ;; Query time: 25 msec
    28. ;; SERVER: 192.168.1.1#53(192.168.1.1)
    29. ;; WHEN: Tue Dec 28 12:39:46 2010
    30. ;; MSG SIZE  rcvd: 228
    31.  
    32. 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.
    text

    1. C:\>whois louisville.edu
    2.  
    3. This Registry database contains ONLY .EDU domains.
    4. The data in the EDUCAUSE Whois database is provided
    5. by EDUCAUSE for information purposes in order to
    6. assist in the process of obtaining information about
    7. or related to .edu domain registration records.
    8.  
    9. The EDUCAUSE Whois database is authoritative for the
    10. .EDU domain.
    11.  
    12. A Web interface for the .EDU EDUCAUSE Whois Server is
    13. available at: http://whois.educause.net
    14.  
    15. By submitting a Whois query, you agree that this information
    16. will not be used to allow, enable, or otherwise support
    17. the transmission of unsolicited commercial advertising or
    18. solicitations via e-mail.  The use of electronic processes to
    19. harvest information from this server is generally prohibited
    20. except as reasonably necessary to register or modify .edu
    21. domain names.
    22.  
    23. You may use "%" as a wildcard in your search. For further
    24. information regarding the use of this WHOIS server, please
    25. type: help
    26.  
    27. --------------------------
    28.  
    29. Domain Name: LOUISVILLE.EDU
    30.  
    31. Registrant:
    32.    University of Louisville
    33.    Information Technology - Communications Services
    34.    109 Miller Info Tech Center
    35.    Louisville, KY 40292
    36.    UNITED STATES
    37.  
    38. Administrative Contact:
    39.    Domain Admin
    40.    University of Louisville
    41.    109 Miller Info Tech Center
    42.    Information Technology Communications Services
    43.    Louisville, KY 40292
    44.    UNITED STATES
    45.    (502) 852-1776
    46.    domain.admin@hermes.louisville.edu
    47.  
    48. Technical Contact:
    49.    Domain Tech
    50.    University of Louisville
    51.    109 Miller Info Tech Center
    52.    Information Technology Communications Services
    53.    Louisville, KY 40292
    54.    UNITED STATES
    55.    (502) 852-1776
    56.    domain.tech@hermes.louisville.edu
    57.  
    58. Name Servers:
    59.    HERMES.LOUISVILLE.EDU           136.165.253.10
    60.    PAN.LOUISVILLE.EDU              136.165.253.89
    61.    HERMES.IPV6.LOUISVILLE.EDU      2610:1e0:1800:f1::1
    62.    PAN.IPV6.LOUISVILLE.EDU         2610:1e0:1800:af1::1
    63.    MIDNIGHT.STATE.KY.US
    64.  
    65. Domain record activated:    11-Sep-1989
    66. Domain record last updated: 17-Feb-2009
    67. 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.

    text

    1. C:\>dig @HERMES.LOUISVILLE.EDU louisville.edu
    2.  
    3. ; <<>> DiG 9.3.2 <<>> @HERMES.LOUISVILLE.EDU louisville.edu
    4. ; (1 server found)
    5. ;; global options:  printcmd
    6. ;; Got answer:
    7. ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2023
    8. ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 5, ADDITIONAL: 6
    9.  
    10. ;; QUESTION SECTION:
    11. ;louisville.edu.                        IN      A
    12.  
    13. ;; ANSWER SECTION:
    14. louisville.edu.         3600    IN      A       136.165.238.241
    15.  
    16. ;; AUTHORITY SECTION:
    17. louisville.edu.         3600    IN      NS      hermes.ipv6.louisville.edu.
    18. louisville.edu.         3600    IN      NS      midnight.state.ky.us.
    19. louisville.edu.         3600    IN      NS      pan.ipv6.louisville.edu.
    20. louisville.edu.         3600    IN      NS      hermes.louisville.edu.
    21. louisville.edu.         3600    IN      NS      pan.louisville.edu.
    22.  
    23. ;; ADDITIONAL SECTION:
    24. hermes.louisville.edu.  3600    IN      A       136.165.253.10
    25. pan.louisville.edu.     3600    IN      A       136.165.253.89
    26. hermes.ipv6.louisville.edu. 3600 IN     A       136.165.253.10
    27. hermes.ipv6.louisville.edu. 3600 IN     AAAA    2610:1e0:1800:f1::1
    28. pan.ipv6.louisville.edu. 3600   IN      A       136.165.253.89
    29. pan.ipv6.louisville.edu. 3600   IN      AAAA    2610:1e0:1800:af1::1
    30.  
    31. ;; Query time: 33 msec
    32. ;; SERVER: 136.165.253.10#53(136.165.253.10)
    33. ;; WHEN: Tue Dec 28 12:54:21 2010
    34. ;; MSG SIZE  rcvd: 285
    35.  
    36. 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)


List Price: $49.99 USD
New From: $26.88 USD In Stock
Used from: $15.90 USD In Stock

Pro DNS and BIND (Paperback)


List Price: $44.99 USD
New From: $24.78 USD In Stock
Used from: $2.83 USD In Stock

Share