Host file update windows

Как восстановить содержимое файла Hosts по умолчанию

Аннотация

Рекомендации, приведенные в этой статье, позволяют вернуть содержимое файла hosts к используемому по умолчанию.

Что такое файл Hosts?

Файл hosts используется операционной системой для сопоставления удобных для человека имен узлов с номерами IP-адресов, которые определяют и обнаруживают узел в IP-сети. Файл hosts — это один из нескольких системных ресурсов, которые связаны с сетевыми узлами в компьютерной сети, и является общей частью реализации IP-адреса операционной системы.

Файл hosts содержит текстовые строки, которые состоят из IP-адреса, указанного в текстовом поле, и одного или нескольких имен узлов. Каждое поле отделено пробелом (по историческим причинам часто предпочтение отдают знакам табуляции, но пробелы также используются). Файл также может включать строки с примечаниями, обозначенные символом #, который ставится в начале каждой такой строки. Пустые строки в файле игнорируются.

Если файл Hosts изменяется с по умолчанию, сброс может помочь устранить некоторые проблемы подключения.

Решение

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

Чтобы восстановить параметры файла hosts по умолчанию, выполните указанные ниже действия.

Откройте приложение «Блокнот». Для этого выполните поиск «Блокнота» с помощью Cortana, а затем коснитесь или щелкните значок «Блокнот».

Скопируйте приведенный ниже текст и вставьте его в файл: # 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

В меню Файл выберите команду Сохранить как, введите «hosts» в поле Имя файла (как показано на рисунке ниже) и сохраните файл на рабочий стол.

Закройте приложение «Блокнот».

Найдите %WinDir%\System32\Drivers\Etc с помощью Cortana, а затем выберите значок папки «Файл ».

Коснитесь и удерживайте файл Hosts (или щелкните на нем правой кнопкой мыщи), выберите команду Переименовать и присвойте файлу имя «Hosts.old».

Скопируйте или переместите файл Hosts, созданный на этапе 3, с рабочего стола в папку %WinDir%\System32\Drivers\Etc. Если система предложит ввести пароль администратора, нажмите кнопку Продолжить.

Чтобы восстановить параметры файла hosts по умолчанию, выполните указанные ниже действия.

Откройте приложение «Блокнот». Для этого проведите пальцем от правого края экрана, коснитесь элемента Поиск, введите запрос Блокнот и коснитесь значка Блокнот. Если вы используете мышь, наведите указатель на правый верхний угол экрана, переместите его вниз и щелкните кнопку Поиск, введите запрос Блокнот и щелкните значок Блокнот.

Скопируйте приведенный ниже текст и вставьте его в файл: # 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

Читайте также:  Windows 10 store language

В меню Файл выберите команду Сохранить как, введите «hosts» в поле Имя файла (как показано на рисунке ниже) и сохраните файл на рабочий стол.

Закройте приложение «Блокнот».

Откройте папку %WinDir%\System32\Drivers\Etc. Для этого выполните следующие действия:

Проведите пальцем от правого края экрана, коснитесь кнопки Поиск, введите слово выполнить, а затем коснитесь значка Выполнить. Если вы используете мышь, наведите указатель на правый верхний угол экрана, переместите его вниз, щелкните Поиск, введите выполнить и щелкните значок Выполнить.

В поле Открыть введите команду %WinDir%\System32\Drivers\Etc и нажмите кнопку ОК.

Выберите файл Hosts, выберите команду Переименовать и присвойте файлу имя «Hosts.old».

Скопируйте или переместите файл Hosts, созданный на этапе 3, в папку %WinDir%\System32\Drivers\Etc. Если будет предложено ввести пароль администратора, нажмите или коснитесь кнопки Продолжить.

Чтобы самостоятельно восстановить параметры файла 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 handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost Windows Vista или Windows Server 2008 # 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 Windows XP или Windows Server 2003 # 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 127.0.0.1 localhost

В меню Файл выберите команду Сохранить как, введите «hosts» в поле Имя файла, а затем сохраните файл на рабочий стол.

Читайте также:  Web ускоритель для windows

Нажмите кнопку Пуск и выберите элемент Выполнить, введите команду %WinDir%\System32\Drivers\Etc и нажмите кнопку ОК.

Выберите файл hosts и переименуйте его в hosts.old.

Скопируйте или переместите файл Hosts, созданный на этапе 3, в папку %WinDir%\System32\Drivers\Etc. Если система предложит ввести пароль администратора, нажмите кнопку Продолжить.

Поддержка Windows XP прекращена

Корпорация Майкрософт прекратила поддержку Windows XP с 8 апреля 2014 г. Это могло повлиять на безопасность и своевременную установку обновлений для вашего программного обеспечения. Что это значит и как обеспечить защиту.

Поддержка Windows Server 2003 завершилась 14 июля 2015 г.

Поддержка Windows Server 2003 завершилась 14 июля 2015 г. Это могло повлиять на безопасность и своевременную установку обновлений для вашего программного обеспечения. Что это значит и как обеспечить защиту.

Как найти и отредактировать файл Hosts

В некоторых случаях бывает необходимо отредактировать файл hosts на локальном ПК или удаленном сервере. С помощью этого файла вы можете управлять маршрутизацией трафика и разрешением IP-адресов в имена DNS. Приоритет данного файла позволяет обрабатывать сетевые запросы до их передачи публичным или частным DNS-серверам. Таким образом, реализуется возможность создания своеобразной локальной системы DNS на самой машине.

Сегодня данный файл практически не используется, его функции выполняет служба DNS, преобразующая «имя в адрес» и «адрес в имя». Тем не менее, его использование возможно и сегодня.

Редактирование:

Синтаксис остается одинаковым для всех операционных систем. У большинства файлов hosts несколько записей для loopback (обратной петли). Мы используем это для примера.

Бесплатный DNS-хостинг

  • Надёжные DNS-сервера
  • Автоматическая миграция
  • API

Часть 1: адрес, куда перенаправить;
Часть 2: адрес, который вы хотите перенаправить;
Часть 3: комментарий.

Они могут быть разделены пробелом, но для удобства чтения, как правило, разделены одним или двумя горизонтальными табуляциями.

127.0.0.1 localhosts #loopback

Используйте любой текстовый редактор в привилегированном режиме для внесения изменений.

Расположение hosts-файла в различных ОС:

Windows

В данном примере будет запрещен доступ машины к сайту Facebook и его поддоменам. Это реализуется за счет разрешения запросов DNS на имя facebook.com в несуществующий IP-адрес 0.0.0.0:

При попытке перейти по заблокированному адресу после добавления строки выше в файл hosts вы увидите ошибку, подтверждающую корректность конфигурации:

How to Edit Your Hosts File in Windows 10

What is a Hosts File?

The hosts file is a local plain text file that maps servers or hostnames to IP addresses. This file has been in use since the time of ARPANET. It was the original method to resolve hostnames to a specific IP address. The hosts file is usually the first process in the domain name resolution procedure. Here is an example of a hosts file entry.

We use the above code as an example since it almost always included in every hosts file. Another example would be similar to the following entry.

  • The first section denotes the IP address where a request will be redirected to.
  • The second section designates the location that we want to redirect a request from.
  • The third section specifies a comment for the entry.
  • Each entry is usually separated by a space or a tab.

We would add the above entry to our hosts file to associate the hostname (or domain name)В liquidweb.comВ with the IP addressВ 67.225.187.61. To provide a working example, let’s move on to the next section.

Why is a Hosts File Useful?

Let’s say we have just completed a migration to a new server. In order to see how our domains will look and operate on our new server before we move our DNS settings, we cannot just type in one of our current domain names as it will resolve to the old server we are moving away from (since we never move our DNS A records from the old server until we are sure the new site is working as expected).

Читайте также:  Включение smb1 windows server 2019

So, to see how our domain will look on the new server, (without having to change our DNS records) we can simply modify our local hosts file to point the domain to the new servers IP. If our domain is liquidweb.com and the old IP is 67.225.187.61 and our new IP will be 72.30.35.10, we can temporarily comment out the current liquidweb.com entry (using a ‘#‘ symbol) and add an alternate entry which points to the new servers IP.

If we added the above entry to our hosts file, every time we open liquidweb.com in our browser, we will now be redirected to the 72.30.35.10 IP.

Where is the Hosts File Located?

The location of the hosts file will differ by operating system. The typical locations are noted below.

  • Windows 10 — «C:\Windows\System32\drivers\etc\hosts»
  • LinuxВ -В «/etc/hosts»
  • Mac OSВ X -В «/private/etc/hosts»

What Does a Hosts File Contain?

A hosts file contains entries similar to the following information. Your entries may differ significantly.

How Do I Edit my Hosts File?

Our \etc\hosts file is only editable as a Windows administrator. В Here is a short video on how to edit a hosts file.

Here are the directions on how to modify your hosts file.

Step 1.
Click the Windows button and type Notepad in the search bar.

Step 2.
Right click on Notepad and then Run as Administrator.

Step 3.
You’ll be asked, “Do you want to allow this app to make changes to your device?”. Choose Yes.

Step 4.
In Notepad, choose File then Open.

Step 5.
Navigate to C:\Windows\System32\drivers\etc\hosts or click the address bar at the top and paste in the path and choose Enter.  If you don’t readily see the host file in the /etc directory then select All files from the File name: drop-down list, then click on the hosts file.

Step 6.
Add the appropriate IP and hostname at the end of your hosts’ file, select Save, and then close the file.

Step 7.
Finally, you will want to flush your DNS cache for your computer to recognize changes to the file. Click the Windows button and search command prompt.

Step 8.
Type the following command in the terminal and press Enter

Conclusion

Modifying a hosts file has many benefits which can significantly impact how you view your new domain or website. Using this method to view a site allows us to see how any new changes affect the layout and functionality of a domain.

Should you have any issues when modifying this file, our Support Teams are filled with experienced Linux technicians and talented system administrators who have an intimate knowledge of how to facilitate this modification. We are always available to answer any inquiries with issues related to this article, 24 hours a day, 7 days a week 365 days a year.

If you are a Fully Managed VPS server, Cloud Dedicated, VMWare Private Cloud, Private Parent server, Managed Cloud Servers, or a Dedicated server owner and you are uncomfortable with performing any of the steps outlined above, we can be reached via phone at 800.580.4985, or via a chat or support ticket to assist you with this process.

Оцените статью