Hosts file
From Free net encyclopedia
In computing, a hosts 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 hosts 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 hosts 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 hosts 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.
Contents |
Location
The hosts file is generally named "hosts" and is located in the following directories for each operating system:
- Linux and other Unix-like operating systems: /etc
- Windows 95/98/Me: %windir%\
- Windows NT/2000/XP: %SystemRoot%\system32\drivers\etc\
- Mac OS: System Folder:Preferences or System folder (format of the file may vary from Windows and Linux counterparts)
- Mac OS X: /etc (uses BSD-style hosts file)
- OS/2 and eComStation: "bootdrive":\mptn\etc\
Ad filtering
One use of the hosts file is ad filtering. This is accomplished by adding a line to the file that maps an ad server's hostname to 127.0.0.1 (home IP), 0.0.0.0 (no IP), or 0(an invalid IP that has fewer bits to it than 0.0.0.0). Then, when an internet-capable program attempts to contact the advertiser, its request is rerouted and no advertisement can be loaded. Since no additional programs are necessary to do this, hosts file based ad-blocking has a near-zero memory and CPU footprint, as well as requiring no loading time. If you want to block an advertiser, right click on the banner or advertisement and click properties. This will give you the URL needed to add to your computer's hosts file.
For example, if you wanted to block Doubleclick ads, you could add the following to your hosts file:
127.0.0.1 ad.doubleclick.net
or
0.0.0.0 ad.doubleclick.net
Another example, if you wanted to block Google Adsense ads, you could add the following to your hosts file:
127.0.0.1 pagead.googlesyndication.com 127.0.0.1 pagead2.googlesyndication.com 127.0.0.1 adservices.google.com
or
0.0.0.0 pagead.googlesyndication.com 0.0.0.0 pagead2.googlesyndication.com 0.0.0.0 adservices.google.com
or
0 pagead.googlesyndication.com 0 pagead2.googlesyndication.com 0 adservices.google.com
Which uses less space and still works.
Hijacking
The hosts file can also be used in malicious ways by the authors of Spyware and Viruses. It is similar to ad blocking with the hosts 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.
Prevention of hosts file hijacking requires realtime monitoring software such as Windows Defender's "Hosts Monitor", which will warn you if anything attempts to edit the hosts file. Changing the properties of the hosts file to read-only is mostly ineffective against modern hijacks as well-programmed malicious software can simply change the file's attribute value. Anti-spyware solutions like Spybot - Search & Destroy and ZoneAlarm's anti-spyware module have a feature to "lock" the hosts file. This does nothing more than set it to read-only. A better way to do this is set the permissions for the file so everyone can only read from it.
Restoration of the hosts file (Windows and Linux)
When a program hijacks the hosts file, it may be necessary to restore it.
- Identify the location of the hosts file for your operating system
- Create a backup copy
- Open it with a basic text editor such as Notepad or Nano
- Remove all entries for the sites which are hijacked. Some may have been added for legitimate programs. Always be sure to back up your hosts file. MAKE SURE THIS LINE IS IN HOST FILE:
127.0.0.1 localhost
- Save the file
- Restart your computer (Windows)
External links
- Abelhadigital's HostsMan 2.1 is a freeware application that lets you manage your hosts file.
- Aldo's Hosts Manager 1.4 is another hosts file manager alternative, though very slim in options.
- Blocking ads on the Internet with a list of ad server hostnames and IP addresses.
- Bluetack HOSTS File and Manager A massive hosts file based on the following sources:
- The Webhelper
- Andrew Clover
- Dan Pollock's hosts file Pretty thorough website, lots of comments, lot of work went into this as shown in his credits.
- Eliminate Web Advertisements The author describes how to combine hosts files with multiple technologies to block advertisements.
- Eric L. Howes contains many good links for security and hosts-file-related stuff.
- Hosts-pider One of the largest public hosts files on the net, with over 100,000 hostnames in the blacklist.
- HOSTS File Myth The author explains his opinion on why using the hosts file to stop malware is false security.
- Hosts file project comprehensive hosts file by Andrew Short.
- MVPS hosts
- Mikes Ad-Blocking hosts file available as a direct download to merge in, or as an installer.
- SCoooBY's fav free apps SCoooBY's huge AD Blocking Hosts File.
- SSMedia hosts file and Utilities hosts file here, available in a weird upload, and then download what isn't there type format. Neat site.de:HOSTS