What a standard hosts file should look like. What does the hosts file do and how to find it

Hey guys! Do you know what it should look like? host file s? One of the important components of any operating system is 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 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!

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 hosts file is slightly 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 of Windows, but not much. 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 principle of its operation is that it helps to 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 won’t go into details of this process; that’s not what the article is about. 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.

  • 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 be opened 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.

    The host file consists of text in English. The main task of the file is to provide data about the IP address of certain domains. In addition, by editing the contents of the file, you can restrict access to certain resources. Only lines that do not begin with a # sign are meaningful to the system. But what should the hosts file look like on a non-infected computer?

    What does the file look like? Windows hosts in the last lines:

    #127.0.0.1 localhost

    What the Windows 10 hosts file should look like (sample):

    Path is the path to the hosts file in different versions operating system Windows various. First, you should open drive C, and then select the path where the hosts file is located, suitable for your operating system, which you can find below.

    Where is the hosts file for Windows 95/98/ME:

    c:\WINDOWS\hosts

    Where is the hosts file for Windows NT/2000 OS:

    c:\WINNT\system32\drivers\etc\hosts

    Where is hosts for Windows 10, 8, 7, XP, 2003, 2000:

    c:\WINDOWS\system32\drivers\etc\hosts


    The Hosts file is a system file that is used to speed up access to the desired site, bypassing the DNS server. Any PC user with administrator rights can check and change the contents of the system hosts file.


    Most often, the contents of the file can be modified by a virus software, the purpose of which is to replace data and redirect you to a “fake” web page or, by interfering with the contents of the hosts file, block the site.

    To avoid infecting your computer with a virus, use an antivirus and scan everything that you download to your PC from unverified sources.

    All changes to the hosts file must be made carefully, because a PC user will not be able to visit the website whose address is registered in the hosts. Editing hosts can be carried out in text editor, for example, in notepad or Notepad program++, to do this you need to open the hosts file in one of the text editors.

    The first way to open the hosts.txt file is:


    How to open the hosts.txt file as an administrator:


    You can open hosts using command line:

    1. Click "Start"
    2. Find "Standard"
    3. Tap right key mouse over “Command Line”
    4. Select “Run as administrator”

    At using Windows 7, enter the code into the command line:

    notepad

    For Windows 8, 10, change the location of the hosts file and paste it into the command line.

    You need to change the Windows hosts file if:

    • You need access to the site bypassing the DNS server
    • You can't access the website you want
    • Instead of desired page another one opens
    • Instead of the required page, you receive a notification that you need to send a paid SMS
    • Another page opens with a slight change in URL
    • Virus attack changed the file itself

    Let's look at an example of why you need to change the hosts file.

    A virus can slip onto a computer or laptop, which can make changes to the contents of the hosts file, for example, replace the address of any site, for example, VK. The user lands on a page that exactly replicates the VKontakte design, except that instead of standard page After authorization, you see a message about the page being frozen. To unfreeze it, you need to send an SMS message with some code to the number indicated on the screen. You send SMS, and from your mobile account a tidy sum is written off.


    Proper Use hosts file will help solve this problem and not fall for scammers, because VK never asks you to send an SMS, for which a fee is charged.

    In Notepad, you can change the hosts file in exactly the same way as any other text file. It's best to copy it to your desktop and configure the hosts file to standard view, that is, remove everything that comes after the lines:

    #127.0.0.1 localhost

    After saving the file, transfer and replace it only to the folder in which it is permanently located as an administrator.


    Ready! You were able to change the hosts file.

    Also make sure that the file does not have an extension. When you change the hosts file in a text editor, its extension automatically changes to .txt. To save the file correctly, specify the value “All files” in the “File type” column.

    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 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. 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 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.