Where are the windows host files

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).

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.

Читайте также:  Где находится ядро linux

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.

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 .

Читайте также:  Диск для сброса пароля windows server 2012 r2

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.

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 File

The hosts file is a file located on your computer that is used as the first step in the DNS lookup process for DNS hostname resolution.

A common use for making changes to this file is to test changes to DNS records before making them live on the Internet as well as setting up custom hostnames for local testing and development.

Where is the hosts file located?

The most common question that many people have around the host file is how do you find it? What is the path and location of the hosts file?

The path of the hosts file varies depending on the operating system that you’re using.

Windows host file location

The hosts file for Windows is located in C:\Windows\System32\Drivers\etc\hosts .

In order to edit this file, you will need to do so as the local system administrator. This can be done by right clicking on the shortcut to your favorite text editor (which can be as simple as Notepad) and choosing the «Run as administrator» option.

Linux host file location

The hosts file for Unix, Linux and other Unix like operating systems is located in /etc/hosts

Apple MacOS host file location

The hosts file for MacOS is located in /etc/hosts as MacOS is a Unix based system and follows many of the common file location conventions.

How do you edit your hosts file?

Once you’ve found the location of your hosts file for your specific operating system, all you need to edit it is a simple text editor. You can use Windows Notepad, TextEdit on the Mac, as well as command line text editors like vim or nano on Unix based systems.

You will need to make sure that when you’re editing this file that you do so with an account which has administrator privileges as this is a protected system file.

Hosts file format

Once you have located the hosts file, the format is very simple. On a new blank line you need to enter the desired IP address followed by a space (or tab) and then the hostname you would like to assign to this. You can add additional hostnames departed by spaces (or tabs) as well.

This process will create a local DNS A record on your system.

or multiple hostnames at once:

Adding comments to your hosts file

It can sometimes be useful to add comments to your hosts file, especially if you have many entries or entries that you switch between from time to time.

To add a comment, you simply need to use the # character, and anything after this will be ignored.

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

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

Читайте также:  Драйвера для ethernet controller windows 10

Зачем нужен файл 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-серверов.

Файл 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 выглядит следующим образом:

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