I am running Windows 7 Home Premium 64-bit. Starting today, I noticed that DNS resolution is not reading my %SYSTEMROOT%\System32\drivers\etc\hosts file. I say this because I added two new entries to the file and when I run 'nslookup' on the command line, they don't resolve. Further, just trying to resolve 'localhost' results in my primary DNS server being queried.

I've read several threads that suggest that the file might have been corrupted and to move it aside and create a new one. I've done that, and no improvement.

Is there some sort of registry key that controls the sequence of resources used for DNS resolution (similar to nsswitch.conf on UNIX)? What else could be causing this?

Thanks in advance.

link|improve this question

I wonder, if you finally found a way to change this Windows 7 64-bit behavior, as I would require both methods (nslookup and ping) providing the same name resolution result! – user94345 Aug 16 '11 at 10:11
feedback

1 Answer

up vote 4 down vote accepted

When you run an nslookup on an address, windows will query the DNS server, and won't look in the hosts file. Always. However, when it actually goes to connect, it will use the host files value. Try adding example.com to your hosts file, and have it point to 127.0.0.1. Run an nslookup: it will resolve to the actual IP. Ping it. Your localhost will respond.

C:\>nslookup example.com
Server:  
Address:  10.110.5.1

Non-authoritative answer:
Name:    example.com
Address:  192.0.32.10


C:\>ping example.com

Pinging example.com [127.0.0.1] with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128

Ping statistics for 127.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:\>
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.