Что должно быть прописано в hosts. Как восстановить файл hosts в Windows. Как отредактировать файл hosts

Что должно быть прописано в hosts. Как восстановить файл hosts в Windows. Как отредактировать файл hosts

12.01.2023

Системный файл hosts - это текстовый файл, в котором содержится локальная база данных доменных имен и их IP-адресов. Запрос к файлу hosts имеет больший приоритет перед обращением к DNS-серверам. Этим и пользуются различные вирусы или вредоносные программы, подменяя его содержимое на свои данные.
Где находится файл hosts?
По умолчанию, системный файл hosts расположен в каталоге .
Чтобы в него попасть надо зайти в меню Пуск Выполнить или нажать комбинацию клавиш WIN+R . В открывшемся окне Запуск программы вводим адрес:
C:\Windows\system32\drivers\etc
или
%WinDir%\system32\drivers\etc
Нажимаем кнопку Enter .

Чтобы его открыть — кликаем на нем правой кнопкой мыши и в меню выбираем пункт Открыть с помощью блокнота
Что должно быть в файле hosts по-умолчанию ?

Файл Hosts для Windows XP:

# Copyright (c) 1993-1999 MicrosoftCorp. # # # space. # # # For example: # 127.0.0.1 localhost

Файл Hosts для 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

Файл Hosts для Windows 7:

# Copyright (c) 1993-2009 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

Файл Hosts для 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

Добрый день. Как-то давно я писал статью о том, в новых операционных системах. В тот момент я как-то не думал о том, что необходимо бы еще написать статью об обратном — как его восстановить до «заводского состояния». Все дело в том, что некоторые «дружелюбные программы»(конечно же, это вирусы), могут изменить его сами и добавить какой-нибудь полезный нам сайт, скажем вконтакте, яндекс, гугл или еще что-нибудь… И после этого мы получаем сообщение о том, что данный сайт не доступен в данный момент. Конечно же, это самое элементарное, проверить файл хостс на наличии лишних записей, но далеко не каждый новичок догадается об этом. Вот для таких людей и будет написана эта небольшая инструкция.

Инструкция


  • А. Отредактировать текущий файл с помощью удалив содержимое и заполнив его следующим:

    # 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

Altered Windows hosts files may prevent game client installation, or cause issues with patching. The hosts file is a Windows system file that can override DNS and redirect URLs or IP addresses to different locations. A typical home internet user will not have a modified hosts file.

Checking for Modifications

  1. Press Windows Key + R .
  2. Type OK .
  3. Open the hosts file with a text editor such as Notepad. Hosts will not have a file extension.
  4. Compare your hosts file with the Microsoft defaults listed below. If yours is different, it has been modified. Remove any lines that contain Blizzard URLs or addresses.
  5. Save the file.

Note: If your hosts file was modified, run a virus scan . Viruses and malware can modify the hosts file to try to redirect your computer to malicious websites.

Common Problematic Modifications

These modifications negatively affect Blizzard games. If you find them, remove them:

  • 127.0.0.1 eu.actual.battle.net
  • 127.0.0.1 us.actual.battle.net
  • 127.0.0.1 enGB.nydus.battle.net

Resetting the Hosts File to Microsoft Defaults

To reset the Hosts file back to the default, follow these steps:

  1. Press Windows Key + R .
  2. Type notepad into the Run window.
  3. Click OK .
  4. Copy the following text to the Notepad window: # 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost
  5. On the File menu, select Save as , type "hosts" (including the quotation marks) in the File name box, and then save the file to the desktop.
  6. Press Windows Key + R again.
  7. Type %WinDir%\System32\Drivers\Etc into the Run window and click OK .
  8. Rename the Hosts file to "Hosts.old".
  9. Copy or move the Hosts file that you created from your desktop to the %WinDir%\System32\Drivers\Etc folder. If you are prompted to enter an administrator password, select Continue .

После ввода в браузере необходимый сайт, предположим Google.com, браузер последовательно (согласно приоритету) ищет сопоставление этого доменного имени IP-шнику (потому что именно с IP адресами работают сетевые устройства).

а) проверяется указанный сайт в hosts-файле, если он находит сопоставление (предположим в hosts-файле прописано 1.1.1.1 Google.com) то соответственно вам откроется содержимое IP - 1.1.1.1, если указного доменного имени нет, переходит к следующему шагу;

б) проверяется кэш-dns (если вы до этого открывали Google.com, то скорее всего IP этого сайта сохранилось в кэше DNS вашего компьютера/ ноутбука), если там указан IP сайта, то вам открывается страница, если нет приступает к на последней стадии;

в) запрос идет к DNS серверу (он прописывается вручную в настройках сетевого подключения или выдается по DHCP), если в DNS сервере нет указанного сайт, он "спросит" у другого DNS сервера, пока его не найдет (если конечно он вообще существует) и сайт успешно откроется.

Файл hosts находится по пути C:\Windows\System32\Drivers\etc\hosts (если С- системный диск). Открыть его можно обычным блокнотом. Если вы не вносили изменения в файл hosts, то там будет прописано следующее:

Файл hosts в Windows XP:
# Copyright (c) 1993-1999 Microsoft Corp.
#
#


# space.
#

#
# For example:
#

127.0.0.1 localhost

Файл hosts в 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 в 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 в 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

Как видите вне зависимости от версии файл host не особо отличаются, но вот если над файлом hosts "поработал" вирус туда могут быть добавленны различные сайты и IP-шники. Например:

127.0.0.1 ftp.kаspеrskylab.ru
127.0.0.1 ids.kаspеrsky-labs.com
127.0.0.1 vk.com
127.0.0.1 drweb.com

Подобные добавления в файле не дают вам зайти на указанные сайты.

1.2.3.4 ftp.kаspеrskylab.ru
1.2.3.4 ids.kаspеrsky-labs.com
1.2.3.4 vk.com
1.2.3.4 drweb.com

Подобные добавления в файле при открытии указанных сайтов перенапрявлют вас на другие сайты, возможно зараженные вирусами (IP- 1.2.3.4- являются вымышленными).

Если вы обноружили, что файл-hosts изменен, его необходимо исправить. В Windows XP файл просто открывается блокноте, вносятся необходимые изменения и сохраняется (необходимо заходить под администратором). На других же версиях (Windows Vista, 7, 8) необходимо дать права на изменение файла. Для этого открываем папку, в которой находится hosts C:\Windows\System32\Drivers\etc (если диск С системный). Нажмите правой кнопкой мыши на hosts и выберете "Свойства".

Выбираете вкладку "Безопасность" , затем выбираете пользователя под которым работаете на компьютере/ ноутбуке (в данном примере это сайт) и нажимаете кнопку "Изменить" . Откроется окно "Разрешения для группы "hosts"" , снова выбираете пользователя и назначаете полные права на файл, нажимаем "ОК", в окне "Свойства: hosts", тоже "ОК" .

После этого открываете hosts Блокнотом и возвращаете файл к исходному состоянию, по окончании сохраняете изменения.

Очень часто, либо после вирусной атаки, после которой, например, социальная сеть для восстановления доступа к Вашей странице, либо после неудачного редактирования, приходится восстанавливать содержимое по умолчанию. Чтобы это сделать, нужно знать, каково содержание оригинального файла hosts. Ситуация осложняется тем, что в каждой операционной системе от корпорации Microsoft, она разная, хотя основное остается прежним. Ниже приведено оригинальное содержимое файла hosts для некоторых ныне популярных операционных систем Windows, которые я перечислю в порядке убывания их популярности(лично я считаю, что самая популярная система — это самая новая система. Кто же считает, что Windows XP бессмертна, а Windows 7 самое лучшее творение Microsoft, мне кажутся людьми отставшими в развитии. Я никого не хочу обидеть, буду только рад услышать, что я не прав).

Для тех, кто не знает, файл Hosts используется для трансляции доменных имен в сетевые . Более подробно о данном файле написано в статье, ссылку на которую я привел чуть выше.

Оригинальный Hosts в 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

Оригинальный файл Hosts в 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

Оринальный файл Hosts в операционной системе Windows Vista

# Copyright © 1993–2006 Microsoft Corp.
#

#




# space.
#


#
# For example:
#


127.0.0.1 localhost:1 localhost

Оригинальный Hosts в ОС 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

Используя приведенные шаблоны, Вы с легкостью можете заменить нынешнее содержимое файла Hosts на его оригинальное содержимое. Кроме приведенных файлов я хотел бы немного уточнить, что тут есть что. Основное содержимое оригинального файла Hosts в Windows — это закомментированный мануал по использованию этого файла на английском языке. Кроме описания функционала файла Hosts, здесь так же приведены различные примеры использования его по назначению. А если Вы до сих пор не разобрались, где находятся комментарии, а где функциональная часть этого файла, то знакомьтесь: знак # является специальным символом, который означает, что всё что находится на данной строке после этого знака — это комментарии. А это значит, что почти что во всех оригинальных файлах Hosts действительно рабочая часть — это последняя строчка с указанием петлевого интерфейса, который является одним из и указывают на сам компьютер. А исходя из этого, можно полностью удалить из файла Hosts все комментарии без утраты его работоспособности. Именно поэтому название статьи — Оригинальный файл hosts в Windows , а не Правильный Hosts для Windows . Ведь правильным файлом Hosts будет являться любая белеберда вроде этой:

# Перед Вами самый правильный из всех
# самых правильных файлов Hosts, который
# когда-либо существовал на компьютерах
# на которых когда-либо была установлена
# операционная система от известной
# корпорации Microsoft!
127.0.0.1 localhost
# Как видите, комментарии везде!
# И тут,
# и там. Но от этого файл hosts
# не становится неправильным!

© 2024 svetlof.ru - Все о компьютере для новичков и профессионалов