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! The name of this file has no extension). Without a unique IP address that identifies computers on a TCP / IP network, you cannot find the computer you need.

IP addresses are presented in the form of groups of numbers - NNN.NNN.NNN.NNN, where NNN varies from 0 to 255 and in this form are difficult to remember and work. To make it easier to remember and access the IP addresses of computers, each IP address is assigned a domain name. The system converts the domain name by which the user accesses a specific computer into the corresponding IP address, and then it is used to establish a connection with the desired computer.

Initially, maintaining a 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 the domain name from the user, the system looks for the corresponding address in the hosts file. The system administrator is responsible for maintaining this list.

Due to the rapid growth of the Internet and the emergence of more and more very large networks, the functions of converting domain names into IP addresses were transferred to Domain Name Servers (DNS). However, the hosts file continues to be used to store the domain names and IP address of the host computers that are most often connected to. This file is processed before the DNS query and therefore has priority which can be used not only to speed up access to the necessary sites, but also to prevent visits to unnecessary ones.

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

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

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

For example, if you write the following line in the hosts: 209.85.229.147 g # google.com then assign the name g to the address 209.85.229.147 and you can go to the google.com search engine website simply after entering one letter g in the address bar of the browser. Pay attention to 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 with one or a couple of letters is more convenient than writing the most popular addresses in favorites.

The hosts file, depending on the version of Windows, is located in different folders: 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 the system folders, which basically shows its importance. However, this is not an obstacle for attackers 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 other parasite. For example, a virus such as W32.Donk.Q writes entries to the hosts file that prevent it from connecting to sites with updates from leading anti-virus manufacturers. In addition to it, there are several more parasites that make entries in this file and interfere with the normal operation of protective programs. Remember that a clean hosts file contains a single working (uncommented) line that 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 at the path specified for your system and right-click on its properties: you need to enable the Hidden, Read-only, and System attributes. Or download a couple of batch files (for XP / 2000 systems) - blocking lockhost.bat and unlocking unlockhost.bat ; for 98 / Me systems - 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 browser and you may receive messages like: Internet Explorer cannot open the Internet site Web address. A connection with the server could not be established or Internet Explorer cannot open the internet site URL: Web site the connection to the server was reset or even go to another page instead of the one requested.

Such problems are described on the Microsoft-a website . In this case, try changing the name of the hosts file 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 error line by placing the # sign at the beginning of the line.

Another problem may arise when using a very large hosts file on XP / 2000 systems - browser brakes.

In this case, it is recommended to disable the DNS Client service: on the command line, run the services.msc command, find the DNS Client in the list of services, right-click in the properties (Propeties) set the Startup type to Manual and reboot.

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

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

	 127.0.0.1 localhost