How to Block Websites By Editing the HOSTS File in Windows

DNS, which stands for Domain Name System, can convert elusive IPv4 or IPv6 addresses into meaningful names, and then translate the characters back to IP addresses. For example, when you want to visit a website, DNS tells your web browser the real IP address of that website, then the web browser loads the website directly from that IP address.

As you might expect, translating IP addresses to website names takes some time, which can cause delays in access. In particular, if the DNS servers go down, you won’t be able to access most websites through their URLs, which is uncommon.

Therefore, it is necessary to create a list to map hostnames to IP addresses. That’s what the Windows HOSTS file does. On most Windows systems, the HOSTS file content is preferred over other methods, such as DNS.

Hostname resolution

With the correct use of the Windows HOSTS file, you can speed up the access of your favorite websites, test websites locally, and even selectively block certain websites (Technet’s image).

In fact, blocking websites through the HOSTS file is an effective way to do it as it blocks it on all browsers (we have previously discussed methods of blocking websites in Internet Explorer and Google Chrome).

This article has some tips for managing the HOSTS file and blocking websites with it. The two methods I will discuss here are:-

  1. How to edit the HOSTS file manually.
  2. How to use a tool called HostsMan editor to make it easy.

1. Edit the HOSTS file manually

Windows NT-based systems including Windows 2000, Windows XP, and Windows 7 have a HOSTS file in the path %SystemRoot%\system32\drivers\etc\ (“%SystemRoot%” is a relative path, depending on the system-wide environment variable it should be C:\Windows or C:\WINNT in most cases).

See more:  How to get money fast in Assassin's Creed: Mirage

Basically, you just need to type the path mentioned above in the Windows search bar (or run box) to get to the “etc” folder where you will find the HOSTS.

You can use any text editor to open the file and edit it manually.

20100804 B02

Note: For Windows 7 users, there is one more step. Type “Notepad” into the Start Menu search bar, then right-click the “Notepad” entry, select “Run as administrator”. Now you can open the HOSTS file using the “File -> Open” menu in notepad.

20100804 B03

The HOSTS file contains lines of text that include an IP address and one or more hostnames. You can add mapping relationship of each site. Comment lines are represented by a hash character (#), which will be ignored by the system.

20100804 B04

To block a website, simply add a line like this:

127.0.0.1 example.com

127.0.0.1 (or Localhost) is the standard hostname given to your computer’s address. You’ve mapped the site name to your PC, so you can’t access the site anymore. So if you want to block Facebook just add this line: 127.0.0.1 facebook.com

2. Edit the HOSTS file with HostsMan Editor

HostsMan Editor (via cybernet news) provides a slick interface for managing your HOSTS files. If you plan to use your HOSTS file often, I recommend this tool.

20100804 B05

As you can see in the screenshot above, the add button can let you add the websites you want to block. You just need to map them to the localhost IP.

You can add, remove or temporarily disable items with this small tool. Furthermore, it can list potential risk categories in the “Possible robberies” section.

See more:  Top 5 Ways to Add Date and Timestamp to Photos on Android

So it’s about how to use the HOSTS file in Windows to block websites.

Also, check out our review of OpenDNS, another way to filter websites visited on your computer.

Categories: How to
Source: thpttranhungdao.edu.vn/en/

Rate this post

Leave a Comment