Where is the hosts file in windows

Where is the Hosts File on Windows x64?

[A German translation of this article is available at faq-o-matic.net.]

The subtle differences between 32-bit and 64-bit Windows present so many intricacies and pitfalls that even Microsoft employees seem to have trouble getting it right. I just stumbled upon a KB article that describes how to reset the hosts file to its original state. The topic alone is funny enough – it is not as if the default hosts file contained great amounts of data. An entry for localhost (IPv4 and IPv6) is all you need, and on Windows 7 / Server 2008 R2 not even that. But anyhow, there seem to be enough people asking MS support for this or they would not have troubled with creating a package (ResetHOSTSFileBackToDefaults.MSI) that basically empties the hosts file.

Is Hosts 64-bit or 32-bit?

As always, I am more interested in what the package does, and Microsoft is kind enough to explain that in most “Fix it for me” articles. As you probably know, the hosts file was, is and probably will always be located in %systemroot%\system32\drivers\etc . Simple enough. But wait: 64-bit systems have two system32 directories: one for 64-bit processes and the other for 32-bit processes. Now, where would the hosts file be located – or are there even two (potentially different) files?

The answer is: no, the hosts file exists only once on x64 Windows. And it is right where it belongs, in the 64-bit system32 directory. But where is that directory located on disk? Is it the one natively called system32 , or is it SysWOW64 ?

Redirection Confusion

This is where confusion kicks in. Many people, including the person writing MS KB article 972034, see the number “64” in the name of the folder SysWOW64 and think: yes, that must be the 64-bit version of system32 . Nice thinking, but wrong. It is exactly the other way round. For compatibility reasons, the name of the system32 folder did not change in Windows x64, although on 64-bit platforms the folder does not contain 32-bit but 64-bit executables! That leaves the question of where to put the 32-bit files that 32-bit processes need – and also expect to find in system32 ? Obviously, the same DLL cannot be present twice in the same folder.

The requirement of two different system32 directories was solved by redirection. Actually there are two independent folders in any x64 installation: system32 and SysWOW64 . The latter is shown to 32-bit processes under the name system32 . 64-bit processes do not use SysWOW64 .

How to Get to and Edit the Hosts File

If you want to edit the hosts file, you first need to locate and open it – on Vista and newer with UAC enabled from an elevated process (with admin rights). The procedure is a little tedious. Here is how to do it with 64-bit Notepad:

  • Click on the Start button, type “notepad” and press CTRL+SHIFT+ENTER. Acknowledge the UAC dialog.
  • Type CTRL+O. Navigate to C:\Windows\System32\drivers\etc . Select “All Files” in the bottom right corner.
  • Now you see the hosts file. Select and open it. Make your changes and save it.
Читайте также:  Вдруг перестал загружаться windows

If you want to access hosts from a 32-bit process, use one of the following paths. Please note that in both cases the full path must be used. Navigating to “etc” from the root does not work (because System32 is redirected and Sysnative is not shown in directory listings).

  • %Windir%\System32\drivers\etc . This works because file system redirection is disabled for the “etc” directory and thus accessing the 64-bit System32 works from a 32-bit process.
  • %Windir%\Sysnative\drivers\etc . Sysnative is an alias that can only be used from 32-bit processes to access the 64-bit System32 directory.

Где находится файл hosts и как его изменить

Файл hosts — текстовый документ, который содержит в себе информацию о домене и адресе, на который ссылается домен.досту Файл hosts появился во времена зарождения Интернета (ARPANET) и служил где лежит неким маршрутизатором, пока на замену ему не пришла служба DNS. Но до сих пор он не утратил важности и по-прежнему используется как инструмент, который обладает приоритетом перед обращением к DNS-серверам.

Зачем нужен файл hosts

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

Где находится файл hosts

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

Windows XP, 2003, Vista, 7, 8, 10 — c:\windows\system32\drivers\etc\hosts

Linux, Ubuntu, Unix, BSD — /etc/hosts

Редактировать файл etc hosts нужно от имени администратора, иначе вы не сможете сохранить внесённые изменения.

Как внести изменения в файл hosts

Ниже мы рассмотрим, как редактировать и как сохранить файл hosts. Важно открыть файл с правами администратора, иначе система не даст вам его сохранить. Выберите вашу операционную систему и следуйте инструкции:

Запустите Блокнот или любой другой редактор от имени администратора. Откройте Пуск, найдите нужный редактор, нажмите по нему правой кнопкой мыши и выберите Запуск от имени администратора:

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

В меню «Файл» нажмите Открыть и перейдите в каталог, в котором расположен файл hosts. Измените тип файла на «Все файлы»:

Добавьте в конце файла необходимую запись в формате:

123.123.123.123 faq-reg.ru www.faq-reg.ru

123.123.123.123 — IP-адрес вашего сервера или хостинга,

faq-reg.ru — имя вашего домена.

Теперь вы можете открыть ваш сайт в браузере, не дожидаясь обновления DNS-серверов.

Чтобы изменить файл hosts в виндовс 10 (8), выполните следующие действия:

Запустите Блокнот или любой другой редактор от имени администратора. Для этого найдите его в Пуске, нажмите по нему правой кнопкой мыши и выберите Запуск от имени администратора:

В меню «Файл» нажмите Открыть и перейдите в каталог, где находится файл hosts . Измените тип файла на «Все файлы»:

Добавьте в конце файла необходимую запись в формате:

123.123.123.123 faq-reg.ru www.faq-reg.ru

123.123.123.123 — IP-адрес вашего сервера или хостинга,

faq-reg.ru — имя вашего домена.

Теперь вы можете открыть ваш сайт в браузере, не дожидаясь обновления DNS-серверов.

В Linux файл hosts находится в папке etc. Чтобы отредактировать его:

Введите в терминал linux команду hosts: sudo nano /etc/hosts

Добавьте в конце файла необходимую запись в формате:

123.123.123.123 faq-reg.ru www.faq-reg.ru

123.123.123.123 — IP-адрес вашего сервера или хостинга,

faq-reg.ru — имя вашего домена.

Теперь вы можете открыть ваш сайт в браузере, не дожидаясь обновления DNS-серверов.

Читайте также:  Что такое windows threshold

Файл hosts в Ubuntu редактируется так же, как и во всех Unix-системах.

Файл hosts в Mac OS расположен в каталоге: /private/etc/hosts. Чтобы изменить его:

Введите команду: sudo nano /etc/hosts и нажмите Enter:

Добавьте в конце файла необходимую запись в формате:

123.123.123.123 faq-reg.ru www.faq-reg.ru

123.123.123.123 — IP-адрес вашего сервера или хостинга,

faq-reg.ru — имя вашего домена.

Теперь вы можете открыть ваш сайт в браузере, не дожидаясь обновления DNS-серверов.

Также вы можете заблокировать определенный сайт через файл hosts, воспользовавшись инструкцией ниже:

Блокировка доступа к сайту через файл hosts

Доступ к сайту также можно ограничить для локального компьютера. Для этого укажите адрес страницы (домен) в файле hosts. Заблокировать IP нежелательного сайта не требуется. Блокировка осуществляется по локальному хосту с фиксированным IP (127.0.0.1):

В указанной на скриншоте строке укажите IP-адрес 127.0.0.1 и через пробел адрес нежелательного сайта. Чтобы заблокировать несколько сайтов, повторите действие в следующей строке. В примере ниже в файле hosts отказано в доступе (заблокирован доступ) к сайтам «vk.com» и «youtube.com»:

Готово! Доступ к сайтам будет ограничен на определенном ПК.

Оригинальный файл hosts и как его восстановить

Скачать оригинал файла hosts можно на разных ресурсах. Но мы не рекомендуем делать это, так как файл может быть заражен.

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

По умолчанию файл hosts выглядит следующим образом:

How to Lock, Manage, Edit Hosts File in Windows 10

The Hosts file in Windows 10/8/7, is used to map hostnames to IP addresses. This Hosts file is located deep down in the Windows folder. It is a plain text file, and the size of the original default Hosts file is around 824 bytes.

Hosts File in Windows 10

In this post, we will see its location and also how to manage, lock, or edit the Hosts file.

Host file location

The Hosts file in Windows is located at the following location:

Lock Hosts file to prevent hijacking

Imagine clicking on www.thewindowsclub.com and seeing a completely different website load in your browser. Malware can redirect Web addresses on your computer by altering your Hosts file. This is referred to as the Host File Hijack.

To prevent Host file hijacks, you may navigate to it, right-click on it, select Properties and make it a Read-only file. This will lock down your Hosts file and prevent anyone or any malware from writing to it.

Block website using the Hosts file

To block a website using the Hosts File, simply add the following entry:

Although I do not do it, many users like to manually add entries to it in order to block the opening of one or more particular websites. Others, like to download and use List from well-known sources like mvps.org, to add entries which block malware sites from opening.

Edit Hosts file

If you need to edit the Hosts file, navigate to the following folder location:

Here you will see the Hosts file. Right-click on it and select Notepad. Make the changes and Save.

But sometimes, even when you are logged on with administrative credentials, you may receive the following error message:

Access to C:\Windows\System32\drivers\etc\ hosts was denied

Cannot create the C:\Windows\System32\drivers\etc\hosts file. Make sure that the path and file name are correct.

In this case, type Notepad in Start search and right-click on the Notepad result. Select Run as administrator. Open the Hosts file, make the necessary changes, and then click Save.

Читайте также:  Windows update select updates to install

HostsMan

While you can always manually manage or edit Hosts file manually, I would like to suggest that you use a third-party freeware tool like HostsMan to do it.

HostsMan is a feature-rich tool that lets you add, remove, edit entries in the Hosts file. It also lets you easily add third-party Hosts lists that help in blocking malware sites and lets you easily enable or disable the hosts file. It includes a built-in hosts file updater & a hosts editor. It lets you scan the hosts file for errors, duplicates, and possible hijacks – and also lets you create an Exclusion list. One more useful feature it offers is the Hosts file backup manager. Backup your Hosts file to a safe place and use it to restore it, should the need arise.

Hostman also lets you Flush DNS cache, open Hosts with a text editor, count the number of hosts, find duplicates, replace IP, scan hosts for malicious entries, rearrange hosts, manage DNS Client Service and more. In short, its the only Hosts Manager that you will even need. You can download it from its home page. SysMate Hosts File Manager is another tool that lets you do so.

How to manually reset Hosts file back to default in Windows may also interest you.

If your browser has been hijacked, you might find this post on Browser Hijacking and Free Browser Hijacker Removal Tools helpful.

Date: December 23, 2018 Tags: Hosts, Security

Где находится файл hosts и как его отредактировать

Изменить файл hosts в windows не так уж и сложно, причин его изменения может быть несколько, например вы хотите добавить туда IP адреса какого либо из своих новых сайтов что бы он открывался до того как обновятся DNS, или наоборот запретить определенным сайтам открываться.

Файл hosts в windows выполняет полезные задачи и он необходим, по умолчанию в данном файле у вас будут примерно такие значения:

# 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 вам нужно сделать следующее:

Перейти по адресу: C:\Windows\System32\drivers\etc после чего в папке ETC вы увидите искомый файл HOSTS.

Для того что бы изменить (отредактировать) файл hosts нужно кликнуть по нему правой кнопкой мыши и выбрать Открыть после чего вы убидите это меню:

В списке программ вам нужно выбрать Блокнот и нажать Ок, после чего файл hosts откроется как обычный текстовый документ, чем он по сути и является. После внесения правок вам останется его стандартно сохранить, как будто вы отредактировали документ .txt.

На это все, теперь вы знаете как быстро отредактировать файл hosts.

Подписывайте на канал , задавайте по данной теме любые вопросы и я вам обязательно помогу. Так же можете внести предложение по теме ‘Создание и настройка сайтов, уроки по Windows’ и следующая статья будет об этом.

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