- slide 1 of 5
What is the Hosts File?
When you enter a Web site address in your browser, your computer starts the process of resolving the domain name (e.g. www.BrightHub.com) to its IP address (e.g. 220.127.116.11). If for a given domain name your computer finds an entry is the Hosts file the name, resolution does not involve a DNS Server but returns the IP address found in the Hosts file.
In the dynamic World Wide Web it is usually better to leave the name resolution process to the DNS servers which are constantly updated. However, in a number of cases it makes sense correcting Windows Hosts files.
- slide 2 of 5
Example Windows Hosts File
The Hosts file is located in the %WinDir% directory, usually C:\Windows\System32\drivers\etc. It can be opened with a text editor such as notepad. Please find below the content of a Windows Vista default Hosts file:
# Copyright (c) 1993-2006 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
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
# 18.104.22.168 rhino.acme.com # source server
# 22.214.171.124 x.acme.com # x client host
- slide 3 of 5
Adding an Entry to Hosts File
127.0.0.1 is the loop-back IP address of your local computer. So if we inserted the fictive domain UglyAdServer.com
we could prevent nasty ads from showing up while browsing the Web, or stop malicious software from phoning home for example. That way you can in fact block access to all websites using Hosts files. Just make sure you really want to block a domain or send your Web requests to a hard-coded IP-address (e.g. 126.96.36.199 for rhino.acme.com ).
- slide 4 of 5
Correcting Hosts Files
Assume rhino.acme.com, the example domain Microsoft has put in the Hosts file, was a bogus entry and not commented out. Each time you entered rhino.acme.com in your browser you could be taken to a phishing site! Therefore, you would correct suspicious entries in Hosts files by adding a # or deleting the line.
By the way: Top Anti-Spyware/Antivirus programs such as Webroot 6.1 featured in Bright Hub's review Webroot AntiVirus with AntiSpyware 6.1 prevent unauthorized modification of your Hosts file.
- slide 5 of 5
Correcting the Windows Vista Hosts Files
To make any corrections to Windows Vista Hosts files, one has to open Notepad in Administrator mode: Right-click %SystemRoot%\system32\notepad.exe and select Run as administrator; the %SystemRoot% folder usually is C:\Windows. Then go to %WinDir% \System32\drivers\etc and make any modifications you want to Hosts files. Don’t forget to save your modifications using File --> Save!
For more on Windows Host File tweaking, read Modifying the Hosts File in Windows Vista.
- Author's own experience