Restoring the Windows xp hosts file. What the hosts file should look like

The article covers the following questions: where is 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 “How 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 name s. 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 address bar 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.

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

Where is the hosts file located?

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

In Windows XP and Windows 7, there is a very small and good file, with which you can control your Internet surfing, the vast majority of users personal computer they don’t know about it, and if they do, they prefer to avoid it for fear of doing something wrong; this file is called hosts. Why is it needed?

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

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

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

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

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


The hosts file opens double click right mouse, when prompted to select a program to open the file, select Notepad.

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

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

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

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

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

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

Original hosts file in Windows XP

# (C) Microsoft Corp., 1993-1999

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

# This file contains mappings of IP addresses to hostnames.

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

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

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

# Additionally, some lines may contain comments

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

# from it with the symbol "#".

# For example:

# 102.54.94.97 rhino.acme.com # origin server

# 38.25.63.10 x.acme.com # client node x

127.0.0.1 localhost

Original hosts file in Windows 7

# Copyright (c) 1993-2009 Microsoft Corp.

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

# This file contains the mappings of IP addresses to host names. Each

# entry should be kept on an individual line. The IP address should

# be placed in the first column followed by the corresponding host name.

# The IP address and the host name should be separated by at least one

#space.

# Additionally, comments (such as these) may be inserted on individual

# lines or following the machine name denoted by a "#" symbol.

# For example:

# 102.54.94.97 rhino.acme.com # source server

# 38.25.63.10 x.acme.com # x client host

# localhost name resolution is handled within DNS itself.

#127.0.0.1 localhost

# ::1 localhost

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

127.0.0.1 kaspersky.ru

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

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

127.0.0.1 porno.ru

127.0.0.1 sex.ru

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

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

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

127.0.0.1 localhost

94.100.191.203 mail.ru

A space is required.

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

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

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

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

the virus is working. Read our articles.

In this lesson we will understand what it is hosts file, where it is located, how to change it and what it should be like in normal condition.

Hosts file- a regular file that contains a list of IP addresses that are associated with site names.

It serves as a kind of local DNS server, indicating where the computer should contact when entering a specific address into the browser. Below you can see an example of the contents of such a file.

By default, hosts contains only one IP address (127.0.0.1), which is occupied by your computer.

When we enter a site address in the address bar of the browser, before the site loads, the computer first accesses the hosts file, looks to see whether this address is in the list or not, and only then accesses the DNS servers on the Internet. Unlike servers, we control the file ourselves. If there is no address in it, then the DNS servers are contacted and the site is loaded, but if there is an entry in the file, then the computer looks at which IP address it should contact.

Hosts can be used to block access to Internet resources. To do this, add immediately after the line 127.0.0.1 localhost new line type:

127.0.0.1 site_address

The site address is matched to the computer's IP address and therefore does not load.

Below are the features of editing the hosts file:

Each entry must be on a separate line;
- IP address in recording in progress first;
- IP and site address must be separated by at least one space;
- the hash symbol # at the beginning of a line allows you to comment it out, i.e. make sure it doesn't work.

Very often, the hosts file is used by attackers. The virus replaces or edits the file so that when you type a certain address, it is not the original site that opens, but the site of the attackers, which is very similar to the real one. In addition to redirection, blocking can be used when scammers simply block access to the site.

Where is hosts located?

Now let's figure it out where is hosts located?. Find hosts can be found at:

C:\Windows\System32\drivers\etc

The path presented above is relevant for the Windows operating system. For other OSes this path may be different.

The file location can be changed in the registry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\DataBasePath

How to change the hosts file.

The hosts file does not have an extension, so you cannot open it by simply double-clicking on it with the left mouse button. Right-click on it and select "Open with".

What should the hosts file look like?

Below are the original texts of the hosts files for different Windows operating systems. This is the default file content.

Windows XP

# Copyright (c) 1993-1999 Microsoft Corp.
#
#
# entry should be kept on an individual line. The IP address should

#space.
#

#
# For example:
#
#102.54.94.97 rhino.acme.com
# source server
127.0.0.1 localhost

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
# 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:
#
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost
::1 localhost

Windows 7

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
#space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a "#" symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

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

In conclusion, I would like to talk about how to protect yourself from hosts changes. Of course, antiviruses come first. Be sure to use them and keep the database up to date. Also, I recently wrote about a program called Browser Manager. It allows you to track and prevent changes to a file without your participation. And of course, do not install unverified programs and do not run strange files.

If you have any questions, be sure to ask them.

In this lesson I will try to convey to you what it is and how to recognize it.

Hello 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, which block access to anti-virus 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.

For 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 here is what the hosts file looks like in the Windows Vista, Windows 7 and Windows 8 operating systems.

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 in its 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 the following command in the “Run” window: %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!

Very often, or after a virus attack, after which, for example, social network 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 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 in almost all original Hosts files the really working part is the last line indicating the loopback interface, which is one of the and pointing to the computer itself. Based on this, you can completely remove all comments from the Hosts file without losing its functionality. That is why the title of the article is The original hosts file in Windows, not Correct Hosts for Windows. After all, the correct Hosts file will be any nonsense like this:

# Before you is the most correct of all
#most correct files Hosts who
# 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!

Share