Network or IT administrators use the Hosts file to either prevent or redirect domain names in their network. For internal use, they will redirect the computers to see the computers in their network. An example of the Hosts file redirection within intranet:
# Copyright (c) 1993-1999 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each entry should be kept on an individual line. The IP address should be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
# For example:
With the above internal usage of Hosts file, the computers in the network will only see the default and portal of Microsoft.com, will try to access domains in the list.
Other usage of a Hosts file is to speed-up browsing, block a malicious website and prevent advertisements.
An example of the said hosts file is similar the above-mentioned hosts file except, the IP address as local host and the listed domain names to be blocked:
127.0.0.1 localhost #IPv4
::1 localhost # IPv6
Using the above hosts file will block or prevent the malicious or unwanted websites.
Location of a Hosts file in Windows 7
The Hosts file in Windows 7 is located in the same directory of the Hosts file in Windows Vista and XP: C:\Windows\System32\drivers\etc
If you are using Windows 2000, you will find it in C:\Winnt\System32\Drivers\etc
Earlier versions of Windows have their Hosts file in C:\Windows
The above applies to 32-bit edition of Windows. If you are using 64-bit, your hosts file is located in any of the following:
You can determine the exact location of the Hosts file by navigating to the registry in Windows:
The User Account Control in Windows Vista and Windows 7 might prevent you in replacing or updating your Hosts file. You need to have a higher permission before replacing the Hosts file. You can also use HostsMan or HostsXpert programs to manage and update your hosts file without the need to deal with UAC. If you need to reset the Hosts file, you can use the Microsoft Fix It 50267.
The Hosts file in Windows is very useful in keeping Windows safe from malicious or unwanted websites. You will need though to monitor the Hosts file to prevent malware and hijackers in redirecting you to their website or preventing you from visiting legitimate websites. Most anti-malware tools should alert you about changes to the Hosts file. If not, you can use WinPatrol to guard your Hosts file.