1

I ran into the following problem under Windows 7: name resolution uses the result from a DNS lookup instead of using what I have in my local hosts file. This is different from previous versions of Windows. What workarounds are there to fix this bug?

Example:

My local hosts file contains the following entries (I disabled IPv6):

#       ::1             localhost
127.0.0.1               localhost
127.0.0.1               svn.mydomain

I can ping svn.mydomain and Windows 7 resolves the name as 127.0.0.1, as expected.

However, nslookup resolves svn.mydomain as 192.168.4.105, which is the entry that comes from my office network's domain nameserver. Windows XP correctly returns 127.0.0.1. I recently moved the server in-house, which is why the svn.mydomain resolves through DNS now, but doesn't when I am outside the office network. I would prefer to not remove that host from DNS.

I specifically put this entry in hosts so I could create a secure tunnel to the Subversion repository on my server (localhost -> svn.mydomain) regardless of my network connection, and it is configured to respond only through a tunneled connection. This bug broke that solution and I'd really like to "resolve" (yes, pun intended) this problem.

How do I keep Windows 7 name resolution from overriding hosts entries?

JdeBP
  • 3,970
  • 17
  • 17
Suncat2000
  • 113
  • 1
  • 5

2 Answers2

5

nslookup will return what the name servers actually return (as the name implies), but that's not the whole picture of name resolution. The hosts file takes priority, and netbios can be used, too.

As you've said, ping is working correctly, as should other applications that use the OS's name resolution functionality. nslookup's ignoring of the hosts file is inconsequential.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • Thanks for the comment. I know that the hosts file __should__ take priority, but that is not what Windows 7 is really doing. I'm trying to find out how to __force__ it to take priority, as it did in previous versions of Windows. – Suncat2000 Mar 15 '11 at 20:57
  • 1
    @Suncat2000 it already is priority; your ping command is evidence of this. nslookup ignores the hosts file, because that's how it works. But, SVN, web browsers, and everything else you might be needing this for, are already obeying your hosts file. – Shane Madden Mar 15 '11 at 20:59
  • 1
    I assumed the identical behavior of my Subversion client and nslookup were due to the same reason. I'm embarrassed to say that was a bad assumption on my part. It was a faulty tunnel configuration that was making the Subversion connection fail. I was unaware that nslookup did not use all name resolution paths. Thanks for that fact. – Suncat2000 Mar 15 '11 at 21:29
0

NSLOOKUP is not going to look at your HOSTS file... you are directly querying your DNS server. Hence, it will return your DNS server's record regardless of your local HOSTS file.

Rob
  • 21
  • 1
  • OK, thanks. But nslookup is behaving the same as my Subversion client, and anybody who would have an answer to my question has access to nslookup. The crux of the matter is that Windows 7's name resolution is somehow broken and I need a way to fix it. – Suncat2000 Mar 15 '11 at 21:00