Install dig On Windows 7, Get dig Working On Windows 7 64-Bit OS
Posted by alex in Insights at 12:19 PMI 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.
- 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.
- 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.
- 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.
- 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”.
- 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>
- 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.
Once the User Accounts screen is open click on “Change my environment variables” in the left navigation which will open the below window.
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.
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.
- 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!
|
|
|
|




Entries (RSS)
On Windows 7 64bit i get an error using whois :-(
C:\Program Files\dns>whois.exe google.com
fgets: Software caused connection abort
[Reply]
alex Reply:
January 20th, 2011 at 4:28 PM
Hello rem,
The article above was written specifically for Windows 7 64-bit. I would suggest following the instructions again from the start to see if it works. If it doesn’t it may be the version of Windows 7 you have installed as the above was completed on Windows 7 Ultimate 64-bit.
Thanks.
alex
[Reply]
rem Reply:
January 24th, 2011 at 2:35 AM
Hi,
I resetup this following your article step by step.
Same result. I find out that it happens not every time and only in .de
could you please try a “dig google.de” on your machine?!
i get the message posted above.
best
rem
[Reply]
alex Reply:
January 24th, 2011 at 9:22 AM
Hello rem,
Weird. Below are the results from “dig google.de” from my Windows 7 64-bit computer.
#############################
C:\>dig google.de
; < <>> DiG 9.3.2 < <>> google.de
;; global options: printcmd
;; Got answer:
;; ->>HEADER< <- opcode: QUERY, status: NOERROR, id: 1749
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;google.de. IN A
;; ANSWER SECTION:
google.de. 300 IN A 74.125.67.106
google.de. 300 IN A 74.125.67.103
google.de. 300 IN A 74.125.67.147
google.de. 300 IN A 74.125.67.104
google.de. 300 IN A 74.125.67.105
google.de. 300 IN A 74.125.67.99
;; Query time: 37 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Mon Jan 24 09:21:18 2011
;; MSG SIZE rcvd: 123
C:\>
################################
Hope that helps.
Thanks.
alex
[Reply]
rem Reply:
January 25th, 2011 at 11:45 AM
Sorry, my fault.
I mean whois google.de.
Dig is working well.
[Reply]
alex Reply:
January 25th, 2011 at 12:21 PM
Hello rem,
This is because whois is set up for the primary domains such as .com, .net, and .org. To accomplish the lookup you are performing use the below syntax.
whois -h whois.denic.de -T dn google.de
Thanks.
alex
dig won’t work for me unless I specify a server like so.
‘dig @ns.mydomain.org’
I did copy the msvcr70.dll to c:\windows\system32 and the resolv.conf to the c:\windows\system32\drivers\etc directory much to the OS’s displeasure.
I also even added my DNS servers to the resolv.conf file. I am running MS Security Essentials and I at first wondered if it or the Windows Firewall were blocking connections but I found that the whois.exe ran great. Here is the output of a failed dig.
; <> DiG 9.3.2 <>
;; global options: printcmd
;; connection timed out; no servers could be reached
Any thoughts on why would be helpful.
[Reply]
alex Reply:
January 28th, 2011 at 9:44 AM
Hello pali,
What operating system are you running? If Windows 7 what version? Are you installing all of these files as administrator? Also I would remove your DNS servers from resolv.conf for now and attempt to get it working without those. Did you try using whois against .com’s instead of .org’s? From the error noted it appears a firewall is blocking your requests… you might try connecting without a firewall.
Thanks.
alex
[Reply]
pali Reply:
January 28th, 2011 at 4:16 PM
Windows 7 64bit. Had to copy the files to c:\windows\system32 and c:\windows\system32\drivers\etc with administrator privileges but my other files are owned by my own user. It turns out that when I copied the resolv.conf to the c:\windows\system32\drivers\etc directory that I also renamed it to be resolve.conf, with a E. That is what screwed me up. Once I renamed to resolv.conf it worked just great. Thanks
[Reply]
alex Reply:
January 29th, 2011 at 9:00 AM
Hello pali,
Good stuff! Glad you got it working. Thanks for taking the time to follow up with what resolved the issue!
Thanks.
alex
[Reply]
Good work! I did all you wrote and everything is ok. Thanks!
[Reply]
alex Reply:
November 24th, 2012 at 5:29 PM
Hello Tiger,
Great to hear! Thanks for taking the time to leave feedback.
Thanks.
alex
[Reply]