This page has been robot translated, sorry for typos if any. Original content here.

Hosts file

I can not get in touch. What to do?

The hosts file associates IP addresses with host names (note that this file name does not have an extension). Without a unique IP address, which identifies computers on the TCP / IP network, you can not find the computer you need.

IP-addresses are represented in the form of groups of digits - NNN.NNN.NNN.NNN, where NNN varies from 0 to 255 and in this form are difficult to remember and work. To facilitate memorization and access to IP-addresses of computers, each IP-address is associated with a domain name. The system converts the domain name by which the user accesses a particular computer to the appropriate IP address, and then uses it to establish a connection to the desired computer.

First keeping the list of host names with their IP addresses was the responsibility of all computers on the network. This list is still stored in the hosts file. Having received from the user a domain name, the system searches the hosts file for the corresponding address. The system administrator is responsible for maintaining this list.

Due to the rapid growth of the Internet and the appearance of ever new and very large networks, the functions of converting domain names to IP addresses have been transferred to DNS servers (Domain Name Server). However, the hosts file continues to be used for storing domain names and the IP address of the host computers, the connections to which are set most frequently. This file is processed earlier than the DNS query and therefore takes precedence which can be used not only to speed up the access to the necessary sites, but also to prevent visiting unnecessary.

This is done simply by adding to the hosts file (open with Notepad) lines 127.0.0.1 www.site.com where 127.0.0.1 is the internal address of your computer (localhost). Thus, the request to the site www.site.com is wrapped in a loop inside the computer and just does not go to the DNS server. In this case, the browser instead of the coveted site will report that it can not open the page. Another curious application of this file is for redirecting requests of unwanted pages to some other site, for example, the website of the Ministry of Internal Affairs :) But this, however, does not apply to our topic.

And what if the unwanted sites are not one and not ten, but hundreds / thousands? - you ask. How to cut them off? Do not write each address with your own hands ... Yes, indeed, you will be stupefied with such work. But part of it has already been done by the creators of programs for managing the hosts file. For example, there is a Hostess program, the author is Ray Marron, which represents the hosts file as a database file. And in this form, you can edit entries in it, add, search for duplicates, etc. Work will become much more convenient. Well, to make things work, you can download ready-to-use hosts files. For example, to lock adult sites, you can take a file from the Rubord forum , there are about 36,000 addresses in it. The file, although not the first freshness, but the most popular sites will be cut off reliably. To cut off all kinds of advertising and banner sites, you can take a finished file on the site winchanger , Mike Meyer or Excel .

Another use of this file is to create a quick access to a certain site.

For example, if you write the following line in hosts: 209.85.229.147 g # google.com then assign the name g to 209.85.229.147 and you can go to the search engine site google.com simply after entering one letter g into your browser's address bar. Note the entry # google.com, the # sign means that everything that goes after it to the end of the line is a comment and is ignored. Sometimes addressing one or two letters is more convenient than writing the most popular addresses in the favorites.

The hosts file, depending on the version of Windows, is in different folders: Windows XP -> C:\WINDOWS\SYSTEM32\DRIVERS\ETC Windows 2K -> C:\WINNT\SYSTEM32\DRIVERS\ETC Windows XP -> C:\WINDOWS\SYSTEM32\DRIVERS\ETC Windows 2K -> C:\WINNT\SYSTEM32\DRIVERS\ETC Win 98 \ ME -> C:\WINDOWS

As you can see, in Windows XP and 2000 the file is hidden from prying eyes in the depths of system folders, which in general shows its importance. However, this is not at all an obstacle for intruders and viruses.

It is clear that not only you can make changes to this file, but also someone else. Including it can be a virus or another parasite. For example, a virus such as W32.Donk.Q writes to the hosts file entries preventing the connection to sites with updates from leading anti-virus vendors. In addition to it, there are several more parasites that make entries in this file and disrupt the normal operation of the protection programs. Remember that a clean hosts file contains a single working (uncommented) line in which it says: 127.0.0.1 localhost

Hence the conclusion: even if you do not intend to use the functions of this important file, you should take care of its safety. The easiest way to change the attributes of a file is to find it according to the path specified for your system and right-click its properties: you must include the Hidden, Read Only, and System attributes. Or download a couple of batch files (for XP / 2000 systems) - locking lockhost.bat and unlocking unlockhost.bat ; for systems 98 / Me - LockHostsME.bat and UnlockHostME.bat and run the desired one.

In conclusion, it should be noted that sometimes incorrect entries in this file can interfere with the operation of the browser and you can get messages like: Internet Explorer Web address. A connection with the server could not be established or Internet access the connection to the server was reset or even get to another page instead of the one requested.

Such problems are described on the Microsoft-a website . In this case, try changing the hosts file name to any other (for example, hosts.txt) and after rebooting try again to go to the same site. Or, if you know exactly where the error is, comment out this erroneous line by putting the # sign at the beginning of the line.

Another problem can arise when using a very large hosts file in XP / 2000 systems - brakes when the browser is running.

In this case, we recommend that you disable the DNS Client service: at the command prompt, run the services.msc command, find the DNS Client service list, right-click the Propeties property, set Startup type to Manual, and reboot.

Yes! All manipulations with the hosts file on XP / 2000 systems must be performed under the administrator's login.

Contents of the original clean hosts file

	 # 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.
	 # 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:
	 #
	 # 102.54.94.97 rhino.acme.com # source server
	 # 38.25.63.10 x.acme.com # x client host

	 127.0.0.1 localhost