- How to Lock, Manage, Edit Hosts File in Windows 10
- Hosts File in Windows 10
- Host file location
- Lock Hosts file to prevent hijacking
- Block website using the Hosts file
- Edit Hosts file
- HostsMan
- Где находится файл hosts и как его отредактировать
- Block Websites Using Hosts File in Windows 10
- To Block Websites using Hosts File in Windows 10,
- How to test the changes
- To Unblock Websites Blocked in the Hosts File,
- About Sergey Tkachenko
- 6 thoughts on “ Block Websites Using Hosts File in Windows 10 ”
- Что такое файл hosts. Как ограничить доступ к сайтам стандартными способами windows
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.
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’ и следующая статья будет об этом.
Block Websites Using Hosts File in Windows 10
How to Block Websites Using the Hosts File in Windows 10
Every Windows version comes with a special Hosts file which helps resolving DNS records. In addition to your network configuration, the file can be used to define a domain=IP address pairing which will have priority above the value provided by the DNS server. Using this trick, you can block certain web sites from opening in the web browser on your computer.
The Hosts file is just a regular text file which can be modified using any text editor. The only catch is that the editor app should be started elevated (as Administrator). The hosts file is located in the system directory, so non-elevated apps will fail to save it.
The Hosts file consists of lines of text. Each line must include an IP address in the first text column followed by one or several host names. Text columns are separated from each other by white space. For a historical reason, is often preferred, but spaces will also do the trick. Lines started with a hash character (#) are comments. Windows ignores blank in the hosts file.
To Block Websites using Hosts File in Windows 10,
- Open the Start menu, and go to Windows Accessories.
- Right-click the Notepad app and select More — Run as Administrator.
- In Notepad, click the File menu — Open, or press the Ctrl + O keys.
- Navigate to the folder C:\Windows\System32\drivers\etc.
- Select «All Files» from the drop-down menu.
- Double-click the hosts file.
- On a new line in the hosts file opened in Notepad, type 127.0.0.1 . This is your localhost address (the default local address of the PC).
- Press Tab or add spaces after you localhost address, and type the web site address (e.g. google.com or www.facebook.com) you want to block.
- Save the file( Ctrl + S ).
Note: Use one entry per line. Entries should look as follows:
How to test the changes
To test the changes you have made, open a command prompt and use the ping command to see the address in the output.
In my case, the remote address of the google.com domain will be resolved to my local computer.
Finally, you might want to unblock a blocked web site. Here’s how it can be done.
To Unblock Websites Blocked in the Hosts File,
- Open the Start menu, and go to Windows Accessories.
- Right-click the Notepad app and select More — Run as Administrator.
- In Notepad, click the File menu — Open, or press the Ctrl + O keys.
- Navigate to the folder C:\Windows\System32\drivers\etc.
- Select «All Files» from the drop-down menu.
- Double-click the hosts file.
- Add the comment symbol # at the beginning of the line that contains the blocked web site you want to unblock. Or, delete the whole line.
- Save the file( Ctrl + S ).
Note: Adding the comment symbol is useful when you want to temporarily unblock an web address, or block/unblock it on demand.
Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:
Share this post
About Sergey Tkachenko
Sergey Tkachenko is a software developer from Russia who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.
6 thoughts on “ Block Websites Using Hosts File in Windows 10 ”
I’ve been using a premade hosts file for years. Get it at “http://winhelp2002.mvps.org/hosts.htm”.
I find it easiest to copy the file to the desktop then delete the old one. Do my editing and then move it back to it’s original location as many security options block modification of this file.
Important Note: The HOSTS file now contains a change in the prefix in the HOSTS entries to “0.0.0.0” instead of the usual “127.0.0.1”.
This was done to resolve a slowdown issue that occurs with the change Microsoft made in the “TCP loopback interface” in Win8.1.
This change in the prefix should not affect everyday users. I’ve had some feedback that COMODO antivirus, and System Mechanic seems to have issues with the “0.0.0.0” prefix … to resolve this issue:
You can use the “Replace” function in Notepad to convert the entries, or either of these freeware utilities (see below) has an option for converting the entries from “0.0.0.0” to “127.0.0.1.
to not have Win8 phone home, but MS still resolves ! it is not working as advertised!
Win8 doesn’t ‘phoning home’ directly to ‘microsoft.com’ it uses a number of other domains with different names, all owned by Microsoft.
I did all the recommendations with updating the hosts file, and it’s still not working. Using windows 10
@Timur – It would help if you list the sites blocked. Here’s the list I’m using.
########################
# Block windows update
########################
127.0.0.1 *.download.windowsupdate.com
127.0.0.1 *.microsoft.com
127.0.0.1 *.update.microsoft.com
127.0.0.1 *.windowsupdate.com
127.0.0.1 *.windowsupdate.microsoft.com
127.0.0.1 download.microsoft.com
127.0.0.1 download.windowsupdate.com
127.0.0.1 ntservicepack.microsoft.com
127.0.0.1 test.stats.update.microsoft.com
127.0.0.1 windowsupdate.microsoft.com
127.0.0.1 wustat.windows.com
It seems complete, but I’ve also shut off every Windows 10 update switch I can find in the registry, so this is just my back-up plan. Good luck.
If anyone can add to the list, that would be great.
There are applications out there to help edit hosts; so you don’t have to go through the rigmarole of searching it out and then remembering you needed to open notepad with admin privs. Not only that, certain apps allow you to work with multiple hosts files (ie, if you are a web dev, etc). Happy blocking!
Что такое файл hosts. Как ограничить доступ к сайтам стандартными способами windows
Для чего нужен файл Hosts?
Предназначение этого системного файла — присвоение определенным адресам сайтов определенного IP.
Этот файл очень любят всякого рода вирусы и зловреды для того, чтобы прописать в него свои данные или попросту его заменить.
Результатом этих действий могут быть признаки «вставки» сайта в браузеры, который будет просить отправить смс при открытии браузера или блокировка различных сайтов, на усмотрение создателей вируса.
Где находится файл hosts в windows?
Для различных версий ОС Windows расположение файла hosts немного разное:
Причем окончание hosts, это уже и есть конечный файл, а не папка. У него нет расширения.
Как должен выглядеть правильный файл hosts?
«Содержимое» файла hosts так же немного отличается для разных версий windows, но не особо. В нем «написано» на английском языке для чего он нужен и как делать исключения с приведением одного примера. Все строчки, начинающиеся со знака # , означают что они закомментированы и не влияют на файл.
Содержание оригинального файла hosts для Windows XP:
# 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 для разных версий windows, особых отличий нет.
Как открыть и изменить файл hosts?
Файл hosts можно открыть с помощью стандартного Блокнота Windows.
Вот здесь, наверное, самая интересная часть статьи.
Прежде всего нужно понять, а зачем вообще изменять этот файл? Да для того, чтобы запретить доступ к определенным сайтам. Таким образом, изменив данный файл и прописав в него адрес сайта, пользователь не сможет зайти на него ни через какой браузер.
Для того, чтобы изменить файл hosts, желательно открыть его от имени администратора (Как запустить файл или программу от имени администратора) щелкнув ПКМ на файле и выбрав «Запуск от имени администратора». Либо открыть таким образом Блокнот и уже в нём открыть файл.
Для быстроты действий можно просто нажать кнопку Пуск и выбрать пункт Выполнить (win+r) (Что делать, если в Пуск нет Выполнить) и ввести в строку:
В результате чего откроется этот файл в Блокноте.
Для того, чтобы заблокировать доступ к сайту (предположим, он будет test.ru ), нужно просто добавить строку с этим сайтом в самый низ:
# 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
# This HOSTS file created by Dr.Web Anti-rootkit API
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 test.ru
Каждый новый сайт, который хотите заблокировать, нужно начинать с новой строки и прописывать, не забывая локальный IP адрес 127.0.0.1
Так же, для редактирования файла hosts, существует программа HOSTS EDITOR, скачать которую и почитать описание можно с официального сайта .
Принцип работы у неё заключается в том, что она помогает отредактировать файл hosts.
Из скрина ниже понятен принцип её работы, всё делается в пару кликов. Добавление осуществляется путем нажатия на + .
После редактирования не забудьте нажать на кнопку сохранения (2 кнопка «Save changes» слева от кнопки «+»).
Так же изменить этот файл можно и для хороших целей, например ускорить загрузку сайта.
Как это работает?
При заходе на сайт, Вы видите его доменное имя, которое имеет буквы. Но все сайты в интернете имеют IP адрес, а названия уже присваиваются с использованием DNS. Я не буду вдаваться в подробности этого процесса, статья не об этом. Но здесь нужно знать то, что файл hosts имеет приоритет при обращении к сайтам, и только после него идет запрос к DNS.
Для того, чтобы ускорить загрузку сайта, нужно знать его IP адрес и домен.
IP адрес сайта можно узнать с помощью различных сервисов, например этого или этого .
Домен — это название сайта.
Для примера, ускорим загрузку этого сайта, на котором Вы читаете статью, явно указав файлу IP адрес и домен.
Тогда добавляемая строчка будет:
Это ускоряет загрузку страницы в пару секунд, а иногда может дать доступ, если стандартными средствами Вы не можете зайти на сайт.
Ещё с можно перенаправить на другой сайт с помощью файла hosts.
Для этого нужно знать IP адрес сайта и его домен (как и в вышеописанном случае), тогда добавляемая строка будет такая:
И теперь, после ввода в адресную строку браузера сайта test.ru , Вы будете перенаправлены на сайт, указанный в IP адресе. В данном случае на сайт vindavoz.ru .
Если хотите почистить файл hosts, то можете это сделать, просто удалив содержимое и вставить в него оригинальный текст, из описания выше (под спойлерами).
Некоторые нюансы в файле hosts:
Таким образом Вы можете легко и бесплатно заблокировать доступ к сайтам в Windows путем правки файла hosts.