DNS: The Hosts file <file name> on the DNS server should be empty

Updated: October 15, 2010

Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012

This topic is intended to address a specific issue identified by a Microsoft Baseline Configuration Analyzer or Best Practices Analyzer scan. You should apply the information in this topic only to computers that have had the DNS Microsoft Baseline Configuration Analyzer or DNS Best Practices Analyzer run against them and are experiencing the issue addressed by this topic. For more information about best practices and scans, see Best Practices Analyzer.

Operating System

Windows Server 2008, Windows Server 2008 R2, Windows Server 2012

Product/Feature

DNS

Severity

Warning

Category

Configuration

Issue

The Hosts file on the DNS server is not empty.

Impact

Errors in the Hosts file on a DNS server can cause problems with name resolution on your network.

The Hosts file is an alternative way to resolve names on your network. By default, host to IP address mappings that are configured in the Hosts file supersede the information in DNS. If there is an entry for a domain name in the Hosts file, then the server will not attempt to query DNS servers for that name. Instead, the IP address that is configured in the Hosts file will be used. If the IP address corresponding to a name changes and the Hosts file is not updated, you may be unable to connect to the host.

Entries in the following files can cause unexpected results during name resolution.

  • %windir%\system32\drivers\etc\hosts

  • %windir%\system32\drivers\etc\hosts.ics

  • %windir%\system32\drivers\etc\lmhosts

Tip

The file %windir%\system32\drivers\etc\lmhosts.sam is a sample file that does not affect name resolution unless you remove the .sam file extension, renaming it to lmhost.

Resolution

Review the entries in your Hosts file.

The Hosts file is located in the %windir%\system32\drivers\etc directory. Review information in the Hosts file, remove or comment the information and, if appropriate, add it to your authoritative DNS server. In the following procedure, replace %windir%\system32\drivers\etc\hosts with the location and filename of the Hosts file you wish to review or configure.

Membership in Administrators, or equivalent, is the minimum required to complete these procedures. Review details about using the appropriate accounts and group memberships at Local and Domain Default Groups (https://go.microsoft.com/fwlink/?LinkId=83477).

To review information in the Hosts file

  1. Open an elevated command prompt.

  2. Type the following command, and then press ENTER:

    type %windir%\system32\drivers\etc\hosts
    

To configure the Hosts file

  1. Open an elevated command prompt.

  2. Type the following command, and then press ENTER:

    notepad %windir%\system32\drivers\etc\hosts
    
  3. Lines that begin with a “#” are considered as comments in the file and are inactive. Add a “#” at the beginning of any lines with host entries you wish to inactivate, or delete the lines from the Hosts file.

  4. When you have completed configuring the Hosts file, click File, click Save, and then close Notepad.