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) the cache DNS is checked (if you have previously opened Google.com, then most likely the IP of this site is stored in the DNS cache of your computer/laptop), if the IP of the site is indicated there, then the page opens to you, if not, it 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 server until it finds it (if, of course, it exists at all) and the site opens successfully.

Hosts file is located along the path 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 inWindows 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, the necessary changes are made and 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 to 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.

Hosts (domain database) - a small document located in the system Windows folders. When you go online and or simply navigate to a website through your browser bookmarks, Windows accesses it first. The main purpose is to compare website names (domains) and their IP addresses, written in numbers. You can go to the site by entering the domain or IP.
It is vulnerable to viruses and other malware that seek to overwrite it

This is done so that you are automatically taken to advertising and virus sites or to block the ability to download certain Internet services. But fortunately, the contents of Hosts are under the control of the user. A notepad program is enough to enter data into a text book or rid it of unnecessary things. Read on to learn how to change hosts in Windows.

How to open Hosts

There is a host database in any OS that can connect to the Internet. And in Windows, and in MacOS, and in Linux distributions. But the location is very different. In XP, Vista, 7 and 8, 8.1 and 10, the hosts file is located at C:\Windows\System32\drivers\etc. You can open it directly in Explorer. The system32 folder is located directly in Windows.

But it’s easier to open the command line from the list of standard programs and enter this in the window: notepad C:\windows\system32\drivers\etc\hosts and press Enter.

Start the command line with administrative rights, otherwise only the preview will open and the change will be blocked.

It will launch in the usual notepad. If command line was initiated by the admin, then the notepad will open in the same way and you can make edits.

There is a third way to open the hosts file in Windows 7, 8, 10 - for the curious:

  1. in Explorer go to C:\Windows\system32;
  2. you need notepad.exe;
  3. right click on it and click on run as administrator.

Next, in a simple way: “File” -> “Open” and look for the one you need. For Notepad to see it, you will need to enable the “All files” option in the lower right corner of the window. So, we figured out how to open hosts as an administrator, it’s time to understand how to edit it and why it is needed.

How to change hosts in Windows 8 or 8.1

The contents of hosts in Windows 7, 8 and 8.1 are the same and look something like this

If you know English well, then at the top you can read a small text about the purpose of the file, but you will probably have it in Russian. We will edit the lower part, adding or deleting addresses.

Line 127.0.0.1 localhost is the local machine you are working on. If your computer does not have an http server running, you can use the address 127.0.0.1 to block unwanted sites. Add the line 127.0.01 site.ru (address of the blocked resource). You can add as many such lines as you like.

The sites included in the list will not open in any web browser on the local machine

The method is suitable for blocking access to sites that are dangerous for children. For the changes to take effect, you need to save the hosts file. The computer needs to be restarted. If you succeed in changing the hosts file in Windows 7, the added sites will not work until you delete entries about them and save them. On the contrary, if a malicious program has added its own entries, you can delete them, thereby opening access to the desired sites or erasing entries about redirection to resources that steal passwords, extort money, or infect your computer.

Editing hosts in Windows 7

Changing hosts in Windows 7 is no different. It is located at the same address and can be edited with notepad using administrator rights. Sometimes it is not possible to change the hosts file. The reason is viruses: some rewrite and do not allow you to change the hosts. Therefore, before you try to rewrite and save, check your computer for viruses. It is advisable to use several programs in turn for an accurate result. On the Internet there is big choice antivirus scanners that do not require installation on your hard drive.

Creating a shortcut for editing hosts

  • To quickly open the domain database, you can place a launch shortcut on your desktop.
  • Click right key on an empty desktop.
  • Next, you need to select “Create” -> “Shortcut”.
Fig.1. In the location of the object, write the line: notepad c:\windows\system32\drivers\etc\hosts

It means that the file at the specified address will be opened by Notepad.

  • Click “Next” and give the shortcut a name so that it opens the desired file with administrator rights.
Fig.2. Right-click on the finished shortcut again and in the shortcut properties go to “Advanced” and specify the requirement to run as administrator

Now you manage domains and IP addresses on your computer.

WATCH THE VIDEO

Now you know how to change the hosts file in Windows. Ask questions to the experts.

What is the Hosts file for?
The purpose of this system file- assigning certain website addresses 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 OS versions 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, this is already the 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 windows versions, 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.
Contents of the original hosts file 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, the contents of the host file for different versions Windows, there are no special differences.

How to open and edit the hosts file?
The hosts file can be found in standard Windows Notepad.
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 writing 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 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 a 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 test.ru into the address bar of your browser, 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 inserting the 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.

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

  • Changes in Windows 8 also affected the hosts file. Now block some sites, including many famous ones social media editing the file will not work, as was possible in previous versions Microsoft operating systems. Why does this happen?

    What are hosts?

    Before connecting to a website, the computer first requests the IP address of the resource. Once it recognizes it, the computer connects to the IP address and accesses the web page. Hosts is a local file for the computer. It allows you to edit website addresses, so access to them can be blocked.

    For example, Vkontakte can be linked to any IP address, including your own. Then, when trying to access this site from a computer, he will not be able to find the web service and, accordingly, go to this resource. In this regard, hosts are used to prevent programs from connecting to developer services if a pirated version of the utility is used. If the hosts file is infected with a virus, you can learn how to remove the Hosts virus, which blocks access to certain sites, from this.

    Why has the file handling changed?

    The developers of Windows 8 tried to install maximum protection against various malware. There are often situations when viruses make various changes in them. Because of this, the user may be on a phishing service without even realizing it.

    In the new operating system, Windows 8 Defender makes sure that no changes are made. On the one hand, this is not bad, since it minimizes the risk of ending up on third-party sites that will infect your computer with a virus. However, there is also a negative side, because you will not be able to block access to unwanted sites yourself. But the latter can be corrected in several ways.

    How to fix hosts in Windows 8

    The easiest way to fix hosts in Windows 8 is to make a copy of it, fix it, and then put it back. To do this, go to drive C, find the folder Windows/system32/drivers/etc. It must be copied to any location, for example, to the Desktop. After that, open it with standard program Notebook.

    We make the necessary changes to it. After that, save the file and send it back to the folder from which you took it. To do this, you need to agree to its replacement. Actually, this is enough to make changes. However, not always this method fits. Therefore, other methods can be used. For example, exclude hosts from Defender program tracking or disable Defender. Detailed instructions Find out how to turn Defender on and off in Windows 8.

    To exclude hosts from tracking, first we find a utility. In the search, enter Windows Defender. Open the application and go to the Settings folder. Here you need to find the Excluded files and locations section. In it, click on the Review link. In the list that opens, select the hosts file. Click on the Add button, after which we confirm the changes made.

    Once you have done the steps above, you will be able to edit the hosts file and operating system won't ignore it. Also, you can make changes if you have administrator rights, and if not, then you need to first. In this case, you will need to right-click on the Notepad program icon. In the list that opens, select run as administrator.

    To edit the hosts file, you can use not only Notepad, but also other editors, for example, Notepad. After you make the necessary changes, web resources will be blocked. You don't even need to restart your computer for the editing to take effect. Often editing the hosts file helps to deny access to certain resources, which can sometimes be very important.

    Of course, the performance of any operating system has its own subtleties and nuances, and this is especially true for everything related to the Internet. And a file such as hosts in Windows 8 is no exception.

    Special purpose

    To understand how to edit hosts in Windows 8, you first need to understand why such a file is needed at all and what it is responsible for.

    Like most everything that exists, the Internet is far from what it seems to the average user at first glance. The average owner of a personal computer or laptop is used to opening a browser, entering a query in the search bar and receiving the information found or the necessary Internet page. But in fact, the PC had to perform where more work, than the user managed to notice.

    As soon as the desired query or address has been entered, the system turns to one important tool - the DNS server. It is responsible for determining and issuing IP addresses to websites and plays the role of a kind of buffer between certain personal computer with its operating system and internet page. After the request has been sent and necessary information received, the connection to the website server and direct downloading begins.

    The hosts file in Windows 8 plays the role of a protective membrane through which specified IP addresses are passed and unknown ones are cut off.

    It has local significance and its own original copy is created on each device with an operating system from Microsoft. And, despite the fact that in most cases it has the same parameters, anyone can change them at their own discretion, of course, with the appropriate knowledge and skills.

    It is through this file You can block connections to certain servers, which will allow you to deny access to content that is undesirable for the user. Also, editing it can be used as “parental control”.

    Setting details

    Before describing where the hosts file is located in Windows 8, you should describe the nuances associated with it.

    The first thing worth mentioning is that this file is the most common target for virus and spyware. Malicious program tries to make changes and add new entries that allow you to connect not to the desired website, but to a pre-prepared one that will engage in sabotage of the PC. The effect will depend on the intended purpose of the virus, its type and the tools at its disposal. Thus, the owner of the device may not even realize that he did not go to the VKontakte page, but to a completely different server, since address bar there will be an inscription “vk.com”.

    The hosts file, due to its importance, is under the protection of a service such as Windows Defender, which does not allow you to make adjustments to it or add new entries.

    When installing third-party antivirus software this service is disabled, and control over the hosts is exercised by the newly installed utility. The degree of control decreases as third party application is more tolerant of working with local data.

    If necessary, the user can remove Defender custody of this file, but this should only be done by experienced users who understand what this can lead to. To do this, you need to open Windows Defender, go to the “Settings” tab, and then select the file of interest in the block of excluded files and locations, which is located at: C:WindowsSystem32Driversetchosts.

    Hosts adjustment

    At the preparatory stage, you will have to perform one small but very important action, without which further manipulations simply do not make sense. Editing the required object is impossible if:

    • Windows Defender protection was not removed. All changes simply will not function, since the operating system will refuse to make adjustments and save them.
    • No third party antivirus was installed software. It has noticeably fewer tools in the environment than the native Defender, and therefore its control will be less soft. This, in turn, will allow the PC owner to correct the file in the key he needs and save the changes.

    Having finished with the preparatory stage, you can move on to the main procedure.

    First of all, you need to launch standard Notepad or any other simple text editor.

    As soon as the corresponding window is displayed on the monitor screen, select the “File” tab in the upper right corner, and then the “Open” position and follow the previously mentioned address.

    Once the file is open, you can start making new parameters. To do this, you need to go down to the end of the entries and, on a new line, add first your local IP, and then the Internet address of the resource itself. Local IP address is of general importance in standard form looks like this: 127.0.0.1.

    Once the data is entered, all that remains is to save the changes and check the results of the work.

    Hosts file in Windows 8: Video