How to create a hosts file in Windows 7. Hosts - what should be there? Hosts File

The Windows 7 operating system has such a file through which you can regulate your visits to sites on the Internet. Mostly people do not know about such a file, and those who know try to ignore it so as not to “perform miracles.” This file is called hosts. Let's look briefly at why it is needed.

Let it be known that when you enter the address of a website in the browser line, a special DNS server located on the Internet immediately changes it to a certain sequence of numbers. This digital series is unique for each site, and site names are needed only for ease of remembering. The hosts file is used to quickly work on the World Wide Web, bypassing requests to the DNS server. In other words, if in the hosts file you write a number sequence corresponding to the name of the site, then you will be taken to it directly, bypassing the DNS server. You just need to register it correctly, otherwise the site won’t load, and even if it does, it won’t be the one you want.

“Computer pests” willingly use the hosts file for their personal interests. A virus, penetrating a computer, very often changes the hosts file. Therefore, if you suddenly encounter restrictions on access to certain sites, first scan your computer to see if viruses have entered it, and only then convert the hosts to its original form.

Where is the hosts file located in Windows 7?

So, let's look at where hosts is located in Windows 7. You can find it in the Windows system folder. It is located on drive C, that is, where the system is installed. Next, find the “System 32” folder, go to “Drivers” and, finally, to “Etc”. The file we need is saved in this folder.

It also happens that you did not find the hosts file, most likely it is simply hidden and the “Do not show hidden files, folders and drives” option is indicated in the settings. In this case, you need to open the “Computer” folder and press “Alt”, an additional menu will appear at the top of the window, in it select “Tools” and “Folder Options”.
In the new window, select the “View” tab and find the “Show hidden files, folders and drives” item, put a checkmark on it. Accept the changes by clicking the “Ok” button. Now go to the “Etc” folder, the hosts file should be displayed.

Now let's look at how you can change the hosts file. Let's proceed as follows:


Where is the hosts file in Windows 10?

The hosts file in the Windows 10 operating system is located in the same place as in Windows 7, that is, on the system drive. In the “Windows” folder, then go to the “System 32” folder, go to “Drivers” and, finally, to “Etc”.

To change a file in Windows 10, you must:

  • Double-click on the hosts file;
  • In the window that appears we find “Open with”;
  • We find among the proposed programs “Notepad”;
  • Click “Ok”;
  • Make changes and save them.
  • If you are a layman in this matter, then it is better not to do anything, but ask for help from a qualified specialist.
  • If something prompts you to make changes yourself, then first make a copy of the file and move it to another folder. If something doesn’t work out for you, you will return a copy of the file.
  • If you did not copy this file and have already made changes, and then your computer starts acting up, then the Internet will help you. Download a similar file from the site and replace yours.
  • Before you change something, think about whether you really need to do it and how important it is for you.

Many ordinary and slightly advanced computer users have been using them for many years and were not aware of the existence of a file named hosts, which does not have a surname (i.e. extension).

But thanks to viruses and the imperfection of operating systems of the Window family (Windows), users had to get to know this “host”, and quite closely.



What is the hosts file for?

In the Windows operating system (XP, Vista, 7, etc.) the file hosts used to associate (map) host names (nodes, servers, domains) with their IP addresses (name resolution).File hosts is a simple text file that does not have any extension (it doesn’t even have a dot :)).

File hosts physically located in the directory:

  • \Windows\System32\drivers\etc\- for Windows 2000/NT/XP/Vista\7
  • \Windows\- for old Windows 95/98/ME

Most often this directory is located on drive C, so in this case the full path to the file is obtained hosts represents:

By default, only one IP address should be specified in a normal hosts file, this is - 127.0.0.1 . This IP is reserved for localhost, that is, for your local PC. There shouldn't be any other addresses there!

File Contents hosts for Windows XP (Russian OS version):



In text form, the contents of the hosts file for Windows XP can be copied from here:

# (C) Microsoft Corp., 1993-1999
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains mappings of IP addresses to hostnames.
# Each element must be on a separate line. The IP address must
# should be in the first column and must be followed by the appropriate name.
# The IP address and hostname must be separated by at least one space.
#
# Additionally, some lines may contain comments
# (such as this line), they must follow the node name and be separated
# from it with the symbol "#".
#
# For example:
#
# 102.54.94.97 rhino.acme.com # origin server
# 38.25.63.10 x.acme.com # client node x

127.0.0.1 localhost

File Contents hosts for Windows Vista (English OS version):

In text form, the contents of the hosts file for Windows Vista can be copied from here:

# Copyright (c) 1993-2006 Microsoft Corp.
#

#




#space.
#


#
# For example:
#


127.0.0.1 localhost
::1 localhost



File Contents hosts for Windows 7 (English version of OS):

In text form, the contents of the hosts file for Windows 7 can be copied from here:

# Copyright (c) 1993-2009 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

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

Using the hosts file

File hosts theoretically can be used to speed up the Internet and reduce the amount of traffic. This is achieved by reducing requests to the DNS server for resources frequently visited by the user. For example, if you use the search engines Yandex and Google every day (sites http://yandex.ru And http://google.ru respectively), then it makes sense in the file hosts after the line " 127.0.0.1 localhost" write the following lines:

93.158.134.11 yandex.ru

209.85.229.104 google.ru

This will allow your Internet browser not to contact the DNS server, but to immediately establish a connection to sites yandex.ru And google.ru. Of course, few people currently do such tricks, if only because of the good modern access speeds.



Restrictions using the hosts file

Some advanced comrades sometimes use the hosts file to block unwanted web resources (for example, erotic content - for children until they grow up and become computer smarter than you). To do this you need after the line 127.0.0.1 localhost also add the bnm line or several lines:

127.0.0.1 address of blocked resource-1

127.0.0.1 addressblocked resource-2

127.0.0.1 addressblocked resource-3

For example:

The essence of this entry is that the specified blocked resource will now be matched by the browser to the IP address 127.0.0.1 , which is the address of the local computer - accordingly, the forbidden site simply will not load.

This function is often used by computer viruses, which add browser redirects needed by attackers to the hosts file:

Most often, redirection is done to a “left” site, which visually does not differ from the real resource, while the user’s login and password are stolen (he enters them into the supposedly real fields of the site) or they simply write that your account is blocked (allegedly for spam, etc. ), pay money or send SMS (also very expensive) to unlock. Simultaneously with redirecting to their website from social networking sites, attackers block using a file hosts access to antivirus program sites.

Attention! Never pay for this! And don't send SMS!

A cell phone can only be used as a means of obtaining a password or unlock code. Those. messages should come to you, not come from you.



Although, if you don’t mind the money, first check with your mobile operator the cost of sending SMS to this number in order to definitely decide that you really don’t mind just giving this amount to someone.

How to edit the hosts file

  1. Each element must be written on its own (separate) line.
  2. The IP address of the site must begin at the first position of the line, followed (in the same line) by a space and followed by the corresponding host name.
  3. The IP address and hostname must be separated by at least one space.
  4. The comment line must begin with the # symbol.
  5. If comments are used in domain name matching strings, they must follow the host name and are also separated by # .

Viruses and hosts file

To prevent their actions from being immediately detected, attackers edit the file hosts in a cunning way. Several options are possible:

1. To the end of the file hosts is added VERY there are many lines (several thousand), and the redirection addresses (most often located at the end) are difficult to notice, especially if you view the contents of the file hosts using the built-in Windows notepad - a very poor editor.

To view the contents and edit the file hosts It's best to use a text editor that shows the number of lines in a document, such as Notepad++.

You should also be alarmed by the rather large size of the hosts file; in the normal state, it cannot be more than a few kilobytes in size!

2. The original hosts file is edited, after which it is assigned the attribute " Hidden" or " System", because by default hidden files and folders are not displayed in Windows operating systems. In the folder C:\WINDOWS\system32\drivers\etc file is created hosts.txt(by default, extensions are not displayed for registered file types, and the system does not accept the file hosts.txt, she only needs hosts), which is either completely empty, or everything is written as it should be in a real file hosts.

3. Similar to the second option, only here the attackers have already provided the option that extensions for registered file types are displayed in the operating system (the user enabled it independently). Therefore, instead of the file hosts.txt the virus creates a file hosts, which has the letter " O"Russian, not English. Visually the file looks like a real one, but is also not perceived by the system.

In this picture the first file hosts- hidden, the virus made changes to it. Second file hosts- not real, it contains the Russian letter " O" in the name, most often this file hosts empty, viruses do not bother to copy the contents from the real file.

Restoring the hosts file

If you have identified similar changes to your file host, everything needs to be restored to its original state. To do this you need to do the following:

  • Disable real-time protection in your antivirus program, because many normal modern antivirus programs (for example, Avira) do not allow changes to the file hosts.
  • Open directory C:\WINDOWS\system32\drivers\etc
  • Enable the display of extensions for registered file types, hidden files, and system files.
  • Click on the file hosts right-click and select the line " Edit with Notepad++":

If you do not have the text editor program Notepad++ installed, I recommend installing it first and not using Notepad. If you don’t currently have the Internet or are just too lazy to download Notepad++, then you can use the poor notepad to edit the file hosts.

To open a file hosts With notepad, you need to left-click on it, a Windows window will appear with the message “ The following file could not be opened..." Set the switch to " Selecting a program from the list manually". Click OK. In the window Program selection" find in the list Notebook and press OK.

  • Edit the contents of the hosts file so that it becomes as indicated at the beginning of this article.
  • Save changes.
  • Activate antivirus program protection (if disabled).
  • Launch your browser and check if you can view the desired sites.

How the hosts file works

When a user types the address (URL) of a site in the browser and presses Enter, the user's browser:

  • Checks in the hosts file whether the entered name is the computer's own name (localhost).
  • If not, then the browser looks for the requested address (hostname) in the hosts file.
  • If a hostname is found, the browser accesses the IP address specified in the hosts file corresponding to that host.
  • If the hostname is not found in the hosts file, then the browser accesses the DNS resolver cache (DNS cache).
  • If a hostname is found in the cache, the browser looks up the IP address stored in the DNS cache for that host;
  • If the hostname is not found in the DNS resolver cache, the browser contacts the DNS server;
  • If the requested web page (site) exists, the DNS server translates the user-specified URL into an IP address;
  • The web browser downloads the requested resource.

Where is the hosts file located?? I can’t access many sites, mostly antivirus programs, friends say I have a virus on my computer, and problems are caused by it. My antivirus program is regularly updated, I heard in Windows XP, there is a hosts file and if you edit it properly, the problem will go away, but if you do it incorrectly, the Internet will completely disappear, can you tell me where it is and how to edit it?

Where is the hosts file located?

  • Note: Do you want to know how virus programs use this very important file, and how you can use this secret weapon yourself for good purposes. What to do when the hosts file is completely missing from the system or you have two hosts files. What to do when your websites do not open: Odnoklassniki, VKontakte, mail.ru, then be sure to read our new article after reading this article.

In Windows XP and Windows 7, there is a very small and good file with which you can control your Internet surfing, the vast majority of personal computer users do not know about it, and if they do know, they prefer to bypass it for fear of doing anything that’s not true, this file is called hosts. Why is it needed?

  • When you enter the name of a site, for example, mail.ru, into the address bar of your browser, know that a special DNS server located on the Internet immediately converts the name mail.ru into a set of numbers, which is a unique IP address for each site, to For example, for mail.ru it is 94.100.191.204. Since the Internet server where the mail.ru website is located does not contain names, but contains only numbers, the names were specially invented for you and me, so that we can remember them more easily. The hosts file is needed to speed up work on the Internet by bypassing access to the DNS server, that is, if you and I write the following information in the hosts file 94.100.191.203 mail.ru, then the mail.ru website will load directly from us, bypassing the DNS server . But you need to register everything correctly, otherwise you won’t get anywhere at all or you’ll end up in the wrong place. This is the “wrong way” that the creators of virus programs use. Now about everything in detail!

The most important thing to remember is that a request to the hosts file in all browsers has priority over access to DNS servers. In simple words, any browser, before making your request, always looks at the information located in the hosts file.

For example, if in the hosts file we enter other information instead of 94.100.191.203 mail.ru, for example 217.20.147.94 mail.ru, then by typing mail.ru in any browser, instead of the mail.ru mail service, we will get to the Odnoklassniki website , since the IP address 217.20.147.94 is the address of the Odnoklassniki website.

Any system administrator, and even a simple user, must guard the hosts file like the apple of his eye. Now about viruses. Virus writers, one might say, are happy to use hosts file for your own purposes. When a virus gets onto a user’s computer, it often changes the file hosts , therefore, if you have problems accessing any sites, first of all you need to check your machine for the presence of malware, and then return the file hosts pristine appearance.

The hosts file is located at the address C:\windows\system32\drivers\etc\hosts, where (C:) is the letter of the system partition, it is this file that decides which sites are worthy of your attention and which are not. The hosts file may be hidden; to see it, you need to enable the system to show hidden folders and files. Computer->Organize->Folder and Search Options->View, then uncheck the itemHide protected system files, and mark the pointShow hidden files and folders and drives


The hosts file opens by double-clicking the right mouse; when prompted to select a program to open the file, select Notepad.

Friends, if you did not find the hosts file in the C:\windows\system32\drivers\etc\ folder, it means the virus has changed the location of the file in the registry key

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\DataBasePath,

By the way, you may have the hosts file where you need it, but the operating system will use the hosts file located in a completely different place. You can find out exactly where the other hosts file created by the virus is by looking at the DataBasePath value. You will need to return the correct value to the key, as in the screenshot.

So we found out where is the hosts file located, now let's learn how to edit it, if you want to simply fix the file automatically (recommended) using the Microsoft Fix it 50267 utility, then go to the website of its creators and do it with two clicks.

Here is a sample of the original hosts file, by default the file should only have one entry 127.0.0.1 localhost

You can directly copy it from me and edit the hosts file using notepad.

Original hosts file in Windows XP

# (C) Microsoft Corp., 1993-1999

# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.

# This file contains mappings of IP addresses to hostnames.

# Each element must be on a separate line. The IP address must

# should be in the first column and must be followed by the appropriate name.

# The IP address and hostname must be separated by at least one space.

# Additionally, some lines may contain comments

# (such as this line), they must follow the node name and be separated

# from it with the symbol "#".

# For example:

# 102.54.94.97 rhino.acme.com # origin server

# 38.25.63.10 x.acme.com # client node x

127.0.0.1 localhost

Original hosts file in Windows 7

# Copyright (c) 1993-2009 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

# localhost name resolution is handled within DNS itself.

# 127.0.0.1 localhost

# ::1 localhost

If we want, we can deny access to some sites completely using this file. You can do this this way: after the numbers 127.0.0.1 you need to enter the domain name of this site. For example, in most cases, a virus program prohibits visiting sites that distribute anti-virus software; in the case of Kaspersky anti-virus, it will look like this:

127.0.0.1 kaspersky.ru

And you and I can use this secret weapon, for example, by protecting our children from accidentally visiting sites with certain content without resorting to programs like Parental Control, for example, we will write:

127.0.0.1 is the name of a site that you consider dangerous.

127.0.0.1 porno.ru

127.0.0.1 sex.ru

The computer will look for the addresses of these sites on the hard drive, you don’t need to enter too many addresses either, the computer will noticeably slow down.

How else can you use the hosts file? It's no secret that only digital addresses are used on the Internet. The names of sites, for example: R emontcompa.ru, were invented so that the common user would remember them more easily. The computer converts letters that we understand, but are not familiar to, into numbers using the DNS service; naturally, it takes a lot of time for the computer to contact remote DNS servers.

To quickly load your favorite site, in the hosts file, you need to specify its address in numbers directly, bypassing the DNS service. For example, we constantly need the mail.ru mail service, since its site IP is: 94.100.191.203, we write this information in the hosts file, first enter the IP, and then the server name.

127.0.0.1 localhost

94.100.191.203 mail.ru

A space is required.

Friends, recently virus writers have come up with a trick if, for example, you open the hosts file

in a notepad, then at first glance nothing suspicious will seem to you, the contents of the hosts file will be standard,

but if you scroll the scroll arrow to the end, to the very end of the hosts file, then there you can find, for example, such malicious entries; of course, they need to be deleted.

After some time, you will need to check the hosts file again; if malicious entries are made again, it means that it is on your computer

the virus is working. Read our articles.

Very often, either after a virus attack, after which, for example, a social network needs to restore access to your page, or after unsuccessful editing, you have to restore the default content. To do this, you need to know what the contents of the original hosts file are. The situation is complicated by the fact that each operating system from Microsoft is different, although the basics remain the same. Below are the original contents of the hosts file for some currently popular Windows operating systems, which I will list in descending order of their popularity (personally, I believe that the most popular system is the newest system. Who thinks that Windows XP is immortal, and Windows 7 is the most the best creation of Microsoft, they seem to me to be retarded in development. I don’t want to offend anyone, I’ll only be glad to hear that I’m wrong).

For those who don't know, the Hosts file is used to translate domain names into network . More details about this file are written in the article, the link to which I provided just above.

Original Hosts in Windows 8


#

#




#space.
#


#
# 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
# :1 localhost
127.0.0.1 localhost

Original Hosts file in Windows 7

# Copyright © 1993–2009 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
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# :1 localhost

Orinal Hosts file in Windows Vista operating system

# Copyright © 1993–2006 Microsoft Corp.
#

#




#space.
#


#
# For example:
#


127.0.0.1 localhost:1 localhost

Original Hosts in Windows XP

# Copyright © 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

Using the templates provided, you can easily replace the current contents of the Hosts file with its original contents. In addition to the above files, I would like to clarify a little what is what here. The main content of the original Hosts file in Windows is a commented manual for using this file in English. In addition to describing the functionality of the Hosts file, there are also various examples of how to use it for its intended purpose. And if you still haven’t figured out where the comments are and where the functional part of this file is, then get acquainted: the sign # is a special character that means that everything on a given line after this character is a comment. This means that in almost all original Hosts files the really working part is the last line indicating the loopback interface, which is one of the and pointing to the computer itself. Based on this, you can completely remove all comments from the Hosts file without losing its functionality. That is why the title of the article is The original hosts file in Windows, not Correct Hosts for Windows. After all, the correct Hosts file will be any nonsense like this:

# Before you is the most correct of all
# the most correct Hosts files, which
# ever existed on computers
# on which it has ever been installed
# operating system from a well-known
#Microsoft Corporation!
127.0.0.1 localhost
# As you can see, comments are everywhere!
# And then,
# and there. But this makes the hosts file
# doesn't get wrong!

Good afternoon. Once upon a time I wrote an article about new operating systems. At that moment, I somehow didn’t think that it would be necessary to write an article about the opposite - how to restore it to “factory condition”. The thing is that some “friendly programs” (of course, these are viruses) can change it themselves and add some site useful to us, say VKontakte, Yandex, Google or something else... And after that we receive a message that this site is not available at the moment. Of course, this is the most basic thing, checking the hosts file for extra entries, but not every beginner will guess this. It is for such people that this small instruction will be written.

Instructions


  • A. Edit the current file by removing the content and filling it with the following:

    # Copyright (c) 1993-2009 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

    # localhost name resolution is handled within DNS itself.
    # 127.0.0.1 localhost
    # ::1 localhost