What should be in a Windows 7 host. What should the Hosts file look like in Windows. Rules for editing the hosts file

Hello friends!
In some situations it is necessary to change or restore hosts file.

In this article I will tell you what it is intended for and how to edit it correctly. I will give an example of how using the hosts file you can speed up, redirect or block access to certain sites.

The hosts file is special text file system, which is responsible for converting symbolic domain names into their corresponding IP addresses and vice versa. In addition to the usual address, an Internet site also has an IP address.

For example, the social network Odnoklassniki has an address like www.ok.ru and IP address 217.20.147.94. By the way, you can enter these numbers in address bar browser and go, but you will be redirected to www.ok.ru.

It should be noted that such domain addresses (www.ok.ru and others) were invented solely for the sake of convenience. Agree, it is much easier to remember the symbolic name (domain) ok.ru than its IP address 217.20.147.94.

However, the server (dedicated computer) on which the ok.ru website is located does not accept such symbolic treatment. To convert a host name to an IP address, the hosts file and a special domain name system (abbreviated as DNS) are used. Moreover, the hosts file has priority over DNS.

When you enter an address, the first thing you do is look at your hosts file, and only then contact the DNS server. Unlike DNS, the hosts file can be edited directly.

I believe that now you understand the importance of the hosts file and understand why most malware seeks to gain access to it.

Using the hosts file

By managing the hosts file, you can speed up access to certain sites or, conversely, limit access to them. You can organize redirection from some pages to other sites. For example, when accessing some prohibited resources, you will be redirected to the website of the Ministry of Internal Affairs.

But the greatest danger comes from malicious software, which, having gained access to the hosts file, will use it for its own malicious purposes. For example, block access to websites, social networks, or the websites of antivirus software companies.

Where is the hosts file located?

Typically, if it is a Windows operating system (NT, 2000, XP, 2003, Vista, 7, 8), the hosts file is located in system partition on drive C. The full address looks like this: C:\Windows\System32\drivers\etc\hosts.

There are more quick way get to the host file. To do this, press the key combination: Win + R or “Start” → “Run”. A window for entering a command will open. Enter the following command:

  • notepad %windir%\system32\drivers\etc\hosts

And here is the host file itself, which by default looks like this:

If there is no hosts file in this folder, then most likely the virus has changed its location in the registry key. Below is a registry key that specifies the path to the folder with the host file:

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

In addition, the hosts file may be hidden. In this case, go to “Folder Options” → “View” and set the value to “Show hidden folders files and disks."

How to edit the hosts file?

The hosts file can be edited in any text editor. For example, in a standard Windows notepad.

Let's look at the editing options and get started block access to the sites mentioned above: vk.com and ok.ru.

The site or sites to which access needs to be blocked are written on a new line; first, the local IP address is indicated at the beginning of the line - 127.0.0.1 .

In our case, the entry looks like this:

127.0.0.1 vk.com
127.0.0.1 ok.ru

Save the changes. Now open the browser and try to go to the address vk.com or ok.ru. As you can see, the hosts file has done its job, and the attempt to connect to these sites failed.

You can also redirect(make a redirect) to another site. To do this, you need to know the IP address of the site where the redirection will be made, and next to it, indicate the domain from which the redirect is being made, separated by a space.

The example below shows that first I entered the IP address of the site yandex.ru (213.180.204.3), and indicated the domain vk.com separated by a space.

This means that when you try to access the vk.com website, you will be redirected to yandex.ru (213.180.204.3).

To speed up the loading of a site, you need to know its IP address and domain. This data is written in the hosts file.

It would seem that everything is simple: you need to register the necessary changes in the hosts file and click “Save”. But the system complains and does not allow you to save the desired changes. More precisely, it suggests saving it to a separate text file.

This is due to stricter security rules in the OS latest versions, and this makes sense, since many viruses try to write their lines here. In this case, the changes are made by us, and this is done purposefully.

You need to do the following. Return to the location of the hosts file and right-click to call context menu, where select “Properties”.

Go to the “Security” tab and select the user under whose name you are working.

Agree with the warning about the reduced security level. Go back and save changes.

There is an easier way to edit the hosts file - using the command line. You can read it.

To restore the default hosts file settings, simply copy and paste the text below:

# 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

127.0.0.1 localhost

This is how you can easily and simply by editing the hosts file, you can block access to sites or perform redirection. That's all for today.

In the next article I will tell you how to edit the hosts file if the Windows system is locked. In addition, I will answer popular questions: “Why can’t I log into Odnoklassniki?”, “Why can’t I log into VKontakte, email and other sites?” Subscribe and don’t miss the release of this article (the article has already been published, you can read it).

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 of the currently popular Windows operating systems, which I will list in descending order of popularity (personally, I believe that the most popular system is the most new system. Those who believe that Windows XP is immortal and Windows 7 is the best creation of Microsoft seem to me to be backward 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 on 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 special character, which means that everything on this line after this sign is comments. This means that almost all original Hosts files actually contain working part- this 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 Original file hosts on 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!

The article covers the following questions: where is the hosts file in Windows 7, Windows 8, Windows 10; contents of the hosts file, how to edit it; how to save the hosts file if access is denied.

Hosts file - what is it, what is it for?

What is this

hosts - a file containing a database of IP addresses and domain names corresponding to them. For example, for the popular site VKontakte the correspondence will be as follows:

87.240.131.118 vk.com

The hosts file on Windows is opened using the application Notebook.

What is it for?

Letter website addresses were invented exclusively for people, since it is easier for a person to remember. Computers find sites by numbers. Using the same VKontakte as an example: vk.com is a letter address (or they say URL), and 87.240.131.118 is a digital address (or IP address).

Check my words. Enter in the address bar of your browser
87.240.131.118
You must go to the site https://vk.com/.

All matches between IP addresses and URLs are stored on DNS servers, which the browser contacts and opens to us the desired site.

But before contacting the DNS server, the browser always checks the hosts file. In it we can prohibit the opening of sites, or replace the correspondence between the IP address and the URL.
This is what viruses do on the computer, replacing matches, adding other lines to this file, etc. For information about the lines that need to be entered into such a file, see the chapter “Like commands that need to be entered

What should the hosts file look like? Contents of the hosts file

The hosts file should have the following:

For Windows XP:

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

#




#space.
#


#
# For example:
#

127.0.0.1 localhost

For Windows Vista:


# Copyright (c) 1993-2006 MicrosoftCorp.
#
# 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
# ::1 localhost

For Windows 7, 8, 8.1, 10:

# 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

Where is the hosts file located in Windows 7, Windows 8, Windows 10

The hosts file is located in all versions of Windows at
See screenshots:

How to open the hosts file

This file can be opened using Notepad. Find it in the start menu this application. Click right click mice. In the menu that appears, select “Run as administrator.” In the Notepad window that opens, through the “File” → “Open…” menu, open the hosts file, writing the file address in the address bar of the window that opens or moving from folder to folder until we find it.

How to edit the hosts file

1. Recovery

To restore a file you need:
  1. Open the file using Notepad as administrator.
  2. Copy the contents of the file from this article, paste with replacement and save.
Attention!
The file should only be opened through Notepad running as administrator. Otherwise, you will not be able to save the changes. When we save the .txt extension in the file name, we remove it.

Tricks of a modified hosts file

1. Some viruses disguise their changes after lines
127.0.0.1 localhost
::1 localhost

They leave a lot of spaces and only then add lines.

Therefore, when replacing content, select all content (hot keys CTRL+A).

2. The file is hidden
If there is no file in the specified package, then it may have been hidden and assigned the “Hidden” attribute.
In the menu View → Options → View, check the box “Show hidden files, folders and disks."




Now that the file has appeared, in the file properties, uncheck the “Hidden” checkbox.

3. Cannot be edited
The file has been assigned the Read Only attribute. In the file properties, uncheck the corresponding box.


To folder C:\Windows\System32\drivers\etc place a file with the name hosts, but with the extension .txt(hosts.txt file) or without an extension, like the hosts file, but with a different name, for example, host.

2. Change

To block access to a certain site, you need to enter the lines at the end of the content
(Skip line)
127.0.0.1 (several spaces) (Domain name to block)
127.0.0.1 (several spaces) (Name of the blocked domain from www.)

Using the example of the same VKontakte and Odnoklassniki:


Save. We check our work by entering the URL of these sites into the address bar of the browser. Sites do not open. Bingo!

This way you can block websites computer games, casino sites, pornographic sites, etc.

To redirect, we do everything as before, but we give the desired URL a different IP.

Example. Let the site https://vk.com/ open when you log in to VKontakte and Odnoklassniki
We write the lines:
(Skip line)
87.240.131.118 vk.com
87.240.131.118 www.vk.com
87.240.131.118 ok.ru
87.240.131.118 www.ok.ru

2.3. Popular sites and their IP addresses

87.240.131.118 https://vk.com/
213.180.193.3 https://ya.ru
5.61.23.5 https://ok.ru/

The Internet is full of services to determine the IP addresses of any websites. Google it.

hosts access denied - what to do

If you cannot save the file and access is denied. We do it in order, trying to save the file after each item.
  1. Open in Notepad as administrator.
  2. Copy the file to your desktop. Change it. The hosts file remaining in the folder C:\Windows\System32\drivers\etc rename it to hosts.old. Copy the hosts file you edited on your desktop to the folder C:\Windows\System32\drivers\etc.
  3. Turn off antivirus. Antivirus programs often ensure that no changes are made to this file. Add file to exceptions Windows Defender. Starting at 8 Windows versions makes sure that no one changes this file.
  4. We set access rights to the file in its properties on the “Security” tab.
  5. If you still can't remove it, go to Safe Mode and try to remove it from under it.

What happens if you delete the hosts file

Nothing will happen. Unless there are problems with your Internet connection. During connection, the IP address 127.0.0.1 will have to be specified manually. It's possible that some programs will ask for localhost instead of 127.0.0.1, which will create another problem.

Windows is far from Linux in terms of systematically using configuration files to configure functionality operating system. First of all, because Windows uses the registry for this.

But still, there are such files in Windows, and it is sometimes useful to know their purpose. An important repository of configuration options includes a file called Hosts. The file name does not have an extension, so when automatic search there is no need to specify it.

In the course of the presentation, we will focus on the seventh version of the OS, as the most widely used by consumers (Microsoft's tricks in the G8 failed to convince users that Metro is cool).

Essentially, we are dealing with a repository of domain names similar to the names DNS servers. The benefit of using it is that the computer owner is able to regulate the priorities of domains when translating them into real network addresses when accessing Internet resources.

File domains take precedence over any external ones DNS addresses, even those specified in the settings network connections. The default storage location in 7 looks like this: %SystemRoot%\system32\drivers\etc\hosts. However, this path is not possible. The system administrator can override it by changing the registry key named HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\DataBasePath. Files with the same name and purpose are included not only in the Windows system environment; they can be found in Unix-like operating systems, Mac-OS and even on the Android platform.

Internal structure of Hosts records and storage manipulation

Although Hosts does not have an extension, from the inside it looks like a regular test file with entries in approximately the following format: 127.0.0.1 localhost. That is, with a structure consisting of a domain's IP address and its symbolic name, separated by spaces or a tab character.

The example given is a mandatory entry in any such file. It corresponds to the address and name of the user's machine itself. All other entries look similar to this one. With the help of the information placed here, the most different tasks. For example:

  • You can associate the name localhost not with the address of the local machine, but with the address of any computer on the enterprise intranet. This is often done system administrators enterprises and organizations.
  • Similar associations can be used to optimize access to external hosts. If you create a record with a range of IP addresses corresponding to the real addresses of the desired sites, then their pages will load faster than when accessing the provider’s DNS database.
  • One more useful option– the ability to organize blocking of unwanted domains (for example, domains of advertising sites). To do this, all such domains are assigned a local machine address – 127.0.0.1

In principle, hosts is an outdated technology, supported for reasons of backward compatibility.

In addition, it has a serious drawback: if the network connection uses an intermediate proxy server, then all storage entries are simply ignored. There are also security concerns.

The fact is that many viruses like to dig into the contents of a file and change it at their discretion. One of the recommendations given during a virus attack is to open the file in Notepad and delete from it all entries located below the localhost entry.


The hosts file establishes a correspondence between the site domain and the server IP. The contents of this file can be edited by the computer administrator.

Simply put, thanks to this file, you can decide for yourself which sites should be blocked and which should be allowed. That's why this file Often used by virus software to block certain sites, as a rule, these are popular resources: social media, search engines, etc.

In general, this file is located at: C:\Windows\System32\drivers\etc . For quick navigation you can click “Start” - “Run” , enter the command %systemroot%\system32\drivers\etc and click OK.

This is how it looks in standard mode, without blocking any sites.

In order to block any site, just add a simple line to this file: “ 127.0.0.1 link to site " For example, in the photo below, I banned the site google.ru.

How to return previous settings.

In order to restore this file in the previous mode, you need to open this file in Notepad in administrator mode and, deleting the extra lines, save the file in the same place and without an extension, i.e. just like it was before. The easiest way to open this file is in administrator mode via the command line. To do this, right-click on the very bottom left corner of the screen, where the start button is located, and select “ Command line(administrator)".

In the window that opens, enter the text: “notepad C:\Windows\System32\drivers\etc\hosts” and press enter. In the file that opens, you can make changes and save them.

If you are not sure which lines exactly need to be deleted, then simply delete all the text from the file, copy and paste the text below.

# 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



2024 wisemotors.ru. How does this work. Iron. Mining. Cryptocurrency.