Jump to content

Hosts (file)

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Grstain (talk | contribs) at 16:30, 29 March 2005 (Location: Macintosh --> Mac OS). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computing, a host file, stored on the computer's filesystem, is used to look up the Internet Protocol address of a device connected to a computer network. The host file describes a many-to-one mapping of device names to IP addresses. When accessing a device by name, the networking system will attempt to locate the name within the host file if it exists. Typically, this is used as a first means of locating the address of a system, before accessing the Internet domain name system. The reason for this is that the host file is stored on the computer itself and does not require any network access to be used, whereas DNS requires access to an external system, which is typically slower.

Location

The host file is located in the following directories for each operating system:

Ad filtering

One useful ability of the host file is that it is capable of ad filtering. This is accomplished by adding a line to the file that contains 127.0.0.1 (home IP) or 0.0.0.0 (no IP). That way, when a internet capable program attempts to access the IP of an advertiser the ad is prevented from appearing.

For example, if you wanted to block Doubleclick ads, you could ad the following to your host file:

127.0.0.1 ad.doubleclick.net

or

0.0.0.0 ad.doubleclick.net

Hijacking

The host file can also be used in malicious ways by the authors of spyware and viruses. It is similar to ad blocking with the host file, but instead of redirecting advertising servers to dummy ones, popular websites are redirected to an advertiser's server. This technique is known as hijacking. The Qhosts trojan hijacked many search engines such as Google and Altavista and redirected them to a site specified by the author.

Other malware such as Mydoom.B may just block the user from visiting sites about security and the removal of viruses. These sites included the makers of popular anti-virus software and Microsoft's Windows Update page to make the removal of the software more difficult for novice users.

Restoration of the Host File (Windows and Linux)

When a program hijacks the host file, it may be necessary to restore it.

  1. Identify the location of the host file for your operation system
  2. Create a backup copy
  3. Open it with a basic text editor such as Notepad or vi
  4. Remove all entries for the sites which are hijacked. Some may have been added for legitimate programs. Always be sure to back up your host file. By default, most systems will only have the following line:
127.0.0.1        localhost
  1. Save the file
  2. Restart your computer (Windows)