When there is a DNS query, what do windows checks first - host file or DNS cache ? In linux I can change my preference using nsswitch.conf. Is there something similar in windows.


They are both tied together in Windows. The displaydns command will show entries that are in the hosts file too. Here's a link to an MS article that explains how it works:

The ipconfig /displaydns command provides you with a means to view the contents of the DNS client resolver cache, which includes entries preloaded from the local Hosts file, as well as any recently obtained resource records for name queries resolved by the system. This information is used by the DNS Client service to quickly resolve frequently queried names before it queries its configured DNS servers.

| improve this answer | |
  • Thanks for your time. Say, I have an entry for a domain name in my cache, and I add an entry for the same domain name mapped to a different IP in my host file, which IP will the DNS query resolve to - The one in my cache or host file ? – Siva Prakash Mar 21 '17 at 9:41
  • 1
    I'm not really sure, but what seems to me from the MS article is that the cache won't have any entries for the same domain that is already routed in the hosts file, because all the hosts file entries are always loaded in the cache right at the beginning. – Yisroel Tech Mar 21 '17 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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