Normal hosts file. Hosts file in Windows. How to find and change? What the hosts file should look like

After entering the required site in the browser, suppose Google.com , the browser sequentially (according to priority) looks for a match between this domain name and the IP addressee (because it is IP addresses that network devices work with).

A) the specified site is checked in the hosts file, if it finds a match (let’s assume 1.1.1.1 Google.com is written in the hosts file), then the contents of IP - 1.1.1.1 will open for you, if there is no specified domain name, proceed to the next step;

b) cache dns is checked (if you have previously opened Google.com, then most likely the IP of this site is saved in DNS cache your computer/laptop), if the IP of the site is indicated there, then the page opens for you, if not, proceeds to the last stage;

V) the request goes to the DNS server (it is registered manually in the settings network connection or issued via DHCP), if the DNS server does not have the specified site, it will “ask” another DNS servers, until it is found (if, of course, it exists at all) and the site opens successfully.

The hosts file is located at C:\Windows\System32\Drivers\etc\hosts (if C- system disk). You can open it with a regular notepad. If you have not made changes to the hosts file, then the following will be written there:

Hosts file in Windows XP:
# Copyright (c) 1993-1999 Microsoft Corp.
#
#


#space.
#

#
# For example:
#

127.0.0.1 localhost

Hosts file in Windows Vista:
#
# 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

Hosts file in Windows 7:
# Copyright (c) 1993-2006 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

Hosts file in Windows 8

# 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

As you can see, regardless of the version, the host file is not very different, but if a virus “worked” on the hosts file, various sites and IPs can be added there. For example:

127.0.0.1 ftp.kasperskylab.ru
127.0.0.1 ids.kaspersky-labs.com
127.0.0.1 vk.com
127.0.0.1 drweb.com

Such additions to the file prevent you from accessing the specified sites.

1.2.3.4 ftp.kasperskylab.ru
1.2.3.4 ids.kaspersky-labs.com
1.2.3.4 vk.com
1.2.3.4 drweb.com

Such additions in the file when opening the specified sites will redirect you to other sites, possibly infected with viruses (IP-1.2.3.4- are fictitious).

If you find that the hosts file has been changed, it needs to be corrected. In Windows XP, the file is simply opened in Notepad and entered necessary changes and is saved (you must log in as an administrator). On other versions (Windows Vista, 7, 8), you must give permission to change the file. To do this, open the folder in which hosts is located C:\Windows\System32\Drivers\etc(if drive C is system). Click right click mouse on hosts and choose "Properties".

Select a tab "Safety", then select the user under which you work on your computer/laptop (in in this example this is the site) and click the button "Change". A window will open "Permissions for the group "hosts"", select the user again and assign full rights on the file, click "OK", in the window "Properties: hosts", Same "OK".

After that, open hosts with Notepad and return the file to original state, save the changes when finished.

What is the Hosts file for?
The purpose of this system file- assignment certain addresses sites of a specific IP.
This file is very popular with all kinds of viruses and malware in order to write their data into it or simply replace it.
The result of these actions may be signs of “insertion” of a site into browsers, which will ask to send an SMS when opening the browser, or blocking of various sites, at the discretion of the creators of the virus.

Where is the hosts file in windows?
For different versions OS Windows location host file s a little different:

Windows 95/98/ME: WINDOWS\hosts
Windows NT/2000: WINNT\system32\drivers\etc\hosts
Windows XP/2003/Vista/Seven(7)/8: WINDOWS\system32\drivers\etc\hosts


Moreover, the ending hosts, it already is final file, not a folder. He doesn't have it.

What it should look like correct file hosts?
The "contents" of the hosts file are also slightly different for different versions windows, but not really. It is "written" in English language why it is needed and how to make exceptions with one example. All lines starting with a # sign mean that they are commented out and do not affect the file.
Content original file hosts for Windows XP:


#

#




#space.
#


#
# For example:
#



127.0.0.1 localhost


Contents of the original hosts file for Windows Vista:

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


Contents of the original hosts file for 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 handle within DNS itself.
#127.0.0.1 localhost
# ::1 localhost


Contents of the original hosts file for Windows 8:

# 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


As you can see, there are no significant differences in the contents of the host file for different versions of Windows.

How to open and edit the hosts file?
The hosts file can be standard Notepad Windows.
This is probably the most interesting part of the article.
First of all, you need to understand why change this file at all? Yes, in order to deny access to certain sites. Thus, by changing this file and having entered the site address into it, the user will not be able to access it through any .
In order to change the hosts file, it is advisable to open it as administrator () by right-clicking on the file and selecting "Run as administrator". Or open Notepad this way and open the file in it.

For quick action, you can simply click the Start button and select Run ( win+r) () and enter in the line:

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



As a result, this file will open in Notepad.

In order to block access to the site(let's assume it will be test.ru), you just need to add a line with this site at the very bottom:

127.0.0.1 test.ru


As a result, the file will have the following content:

# 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

# This HOSTS file created by Dr.Web Anti-rootkit API

#127.0.0.1 localhost
# ::1 localhost
127.0.0.1 test.ru


Every new site you want to block must start with new line and register, not forgetting the local IP address 127.0.0.1

Also, to edit the hosts file, there is a program HOSTS EDITOR, which you can download and read the description from.
The way it works is that it helps edit the hosts file.
From the screenshot below the principle of its operation is clear; everything is done in a couple of clicks. Adding is done by clicking on +.


After editing, do not forget to click on the save button (2 button “Save changes” to the left of the “+” button).

You can also change this file for good purposes, for example speed up site loading.
How it works?
When you access the site, you see it Domain name, which has letters. But all sites on the Internet have an IP address, and names are already assigned using DNS. I will not go into details of this process, this article is not about that. But here you need to know that the hosts file has priority when accessing sites, and only after it does a request to DNS occur.
In order to speed up the loading of a site, you need to know its IP address and domain.
The IP address of the site can be found using various services, for example or .
A domain is the name of a website.
For example, let's speed up the loading of this site where you are reading an article by explicitly specifying the IP address and domain to the file.
Then the added line will be:

91.218.228.14 website


This speeds up page loading in a couple of seconds, and sometimes can give access if standard means You cannot access the site.

Still possible redirect to another site using hosts file.
To do this, you need to know the IP address of the site and its domain (as in the case described above), then the added line will be like this:

91.218.228.14 test.ru


And now, after entering address bar browser of the site test.ru, you will be redirected to the site specified in the IP address..

If you want to clean hosts file, then you can do this by simply deleting the content and pasting into it original text, from the description above (under spoilers).

Some nuances in the hosts file:

  • Always make sure you have a scroll bar on the side and always scroll to the bottom of the window. This is due to the fact that some viruses are registered in an area hidden outside the window.
  • In some cases, usually if you can’t save the file, you need to log in account Administrator.
  • Sometimes, due to viruses, this file may be hidden. Read the article.
  • The two methods described (redirection and acceleration) may not produce the desired result. The fact is that several sites can be located on one IP address, this is especially true for external IP addresses provided by services.
  • Due to the fact that viruses love this file, its attributes can be changed to Hidden And Read-only.
  • Check the file attributes if the hosts file cannot be saved.

    This way you can easily and free of charge block access to sites in Windows by editing the hosts file.

  • 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 needed 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 MicrosoftCorp.
    #

    #




    #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. Right-click. 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 delete 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 “Show hidden files, folders and drives” checkbox.




    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 into 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 from version 8, Windows 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 rather than 127.0.0.1, which will create another problem.

    Hey guys! Do you know what the hosts file should look like? One of the important components of any operating system is the hosts file, and today I will tell you what the hosts file should look like and how to find it among other files. Why is this important to know? The fact is that when any virus attacks, it is the hosts file that is damaged first.


    System failure occurs when the virus independently adds certain entries to the file that block access to antivirus updates, replace real sites with pirated ones, etc. Today I will teach you how to identify such unauthorized entries in this file. Simply open the hosts file using Notepad. If you see entries like this (or something similar)

    • 127.0.0.1 kaspersky.com
    • 127.0.0.1 kaspersky-labs.com
    • 127.0.0.1 liveupdate.symantec.com
    • 127.0.0.1 liveupdate.symantecliveupdate.com

    Then we will have to disappoint you: the file is damaged by a virus.

    We'll talk about file recovery below. Now pay attention to what the hosts file should look like in Windows XP.

    Recovery damaged file download text file and copy its contents to your hosts file. Here you can download a text file with the contents of the hosts file (Windows XP). And this is what the hosts file looks like in operating systems Windows systems Vista, Windows 7 and Windows 8.

    Here the recovery procedure is the same as in the previous case. From this link you can download a text file with the contents of the hosts file (Windows Vista, Windows 7 and Windows 8).

    Now you know what the hosts file should look like. I offer several useful tips on working with him. To restore the hosts file, it is not necessary to save it to original form. When you see the “#” symbol in a file, it means that all the characters coming after this symbol have no meaning. They can be deleted because they do not affect the operation of the system.

    To find the hosts file, go to: WINDOWS\system32\drivers\etc\ folder. To access this folder, enter in the “Run” window next command: %systemroot%\system32\drivers\etc. To open the hosts file, use standard program Notebook. And finally: if you accidentally deleted this file, you can restore it by creating a regular text file and deleting the .txt extension.

    Today you learned not only what the hosts file should look like, but also how to restore or find it. Leave your questions and feedback in the comments line. I was glad to help!

    The hosts file is one of required components operating system, which should normally remain unchanged. If the hosts file differs from the original, then it can be said with a high degree of probability that a virus has taken over the computer. That is why many users want to know what it should look like.

    The hosts file is a text file that has no extension, so it is supported by all operating systems. Essentially, the hosts file is responsible for assigning a unique IP address to websites.

    This file is requested by the browser every time you visit a website, so many viruses are aimed at working with this file.

    The hosts file is located in system folder. In Windows, starting from version XP, the file can be found in the following path:

    Windows\System32\drivers\etc\hosts

    IN in this case hosts is not a folder, but a final file, because it has no extension.

    What should the hosts file look like?

    As we noted earlier, the hosts file differs slightly for different Windows versions, but normally it should always look the same.

    Hosts file for Windows XP

    Hosts file for Windows Vista

    Hosts file for Windows 7

    Hosts file for Windows 8

    Please note that despite the difference hosts contents for different versions of the operating system, each line begins with # . This means that there is a comment here, so it will not affect the operation of the operating system in any way.

    What is the danger of this file?

    If a virus adds its own entries to the hosts file, it can make it so that instead of the requested site, a completely different one may open for you, but you may not even notice this, because attackers can take care of the similarity of the interface.

    How to restore the hosts file?

    Let's assume you went to specified address to the hosts file. To view it, right-click on it and select the menu item “Open with” – “Notepad” .

    If open file contains missing or extra entries, it would be best to delete (return) them. As a rule, such records are the result of viruses.

    If you had to make adjustments to the hosts file, select the menu to accept the change “File” – “Save” .

    At the same time, viruses can resort to some tricks to confuse users who decide to check the hosts file:

    Trick 1. Changes in the file occur after several empty lines.

    For example, you open the hosts file, but do not see any suspicious changes in it. But if you scroll down the file with your mouse wheel, it suddenly turns out that just below are the viral entries, which and .

    Trick 2. The virus can hide the hosts file

    If you went to the “etc” folder, but did not find the hosts file there, then we can assume that it was hidden.

    To do this through "Control Panel" go to menu "Folder properties» . In the window that opens, go to the tab "View" and check the box next to the item "Show hidden files and folders" . Save your changes before exiting. After completed actions hidden file hosts will be displayed.

    Trick 3. False hosts file

    The virus can create a false hosts file, which, as a rule, already has some extension (most often it is .txt). By default, the system does not display file extensions, which means that users can easily be deceived into editing the wrong file.

    Trick 4. False file with a similar name.

    The situation is slightly different: the virus creates a file without an extension, but its name will be slightly different from the original one, for example, host. Such a file is guaranteed to have been created by a virus, so you can safely delete it immediately.

    In conclusion, I would like to summarize that if you encounter a problem with the hosts file, then after editing, be sure to scan the system with your antivirus or use the utility to identify the infection that caused the problem.