top of page

How to block websites using host file on windows 10 (Updated 2022)

On Windows 10 Host file is an important system file that maps the host/site names with its IP addresses. Basically, it translates the hostname to IP and IP to hostname. In other words, the host file is similar to using a phone book to find the matching phone number of a specific person’s name. The host file is a plain text file without any file extension. On Windows computers, We can edit the host files on Windows 10 For custom domain redirects, block websites, or remove malicious entries set by malware. It functions as a local copy of a DNS server.

Contents

Edit hosts File on Windows 10

While Domain Name System or DNS is mostly used for this function (being a centralized and half-automatically managed name resolution system), the HOSTS file can be used as a local name resolution mechanism, and when used in conjunction with other name resolution mechanisms such as DNS, the HOSTS file takes precedence over them. In short, your host file is a form of DNS. Your computer actually looks for your host file before hitting the internet and finding the site you’re searching.

Location of the Hosts File

In Microsoft operating systems, the HOSTS file is located in the following location:

C:\Windows\System32\Drivers\etc

Host File Location

How To Edit Hosts file

Some Times we need to edit the Hosts file, For Different purposes like custom domain redirection, block certain websites, or remove malicious entries set by malware. We can modify the host files using Notepad but, As This is a system file we cant modify this with a normal user account, We need administrator rights. For this, we need to open Notepad As ( Admin )

  1. On Start menu search type notepad,

  2. Right-click on a notepad and select Run as Administrator.

  3. Here on note pad click on file Select open

  4. Browse for the following path: C:\Windows\System32\Drivers\etc

  5. Here Select All Files from the drop-down menu and double click on the host’s file.

open Host files

This will open Host files As Shown Bellow the image.

  1. Here you can custom Redirect domain names,

  2. Block Certain websites ( Domain )

  3. remove malicious entries set by malware.

windows Host File Edit

Note: To modify the host file, you need to add two entries, including the IP address of the remote host or application to the friendly address you want to use.

for example: Type the IP address of the remote host or localhost followed by the domain or computer name you want to use to reach the device or application. Then click on File, and select Save.

How the Hosts File Works

The Host File contains lines of text that are made of IP addresses followed by one or more hostnames or fully qualified domain names (FQDNs). Each field is separated by white space (blanks or tabulation characters).

For example, if you wanted to use the HOSTS file to translate a hostname of a computer called “FTPserver” into the IP address of 192.168.1.100, Then We need to Add Bellow line:

192.168.1.100 FTPServer

The HOSTS file can also translate Fully Qualified Domain Names (or FQDNs) of computers, such as ones used on the Internet.

For example, if you wanted to add a manual line to translate an FQDN of a computer called “webserver.domain.com” into the IP address of 11.06.23.100 you would add this line:

11.06.23.100 webserver.domain.com

When you ping it, your computer will resolve the name to the correct IP address:

Redirect a Website Using Host File

You Can Redirect Any Website to Another website by modifying the Host file. For Ex: you want To Redirect YouTube.com to Twitter.com This means when you open Youtube.com on your web browser it automatically redirects to twitter.com.

For this first, we need Twitter’s IP address. we can get this by using the ping command.

Open the command prompt, type ping twitter.com -t and hit enter key you will see the twitter.com numeric IP address.

get twitter IP

Now on the Host file Add the Twitter IP Space and The Domain Name

104.244.42.193 youtube.com
custom Domain Redirection

This line tells our computer to connect Youtube.com to Twitter’s IP address. Type Youtube.com you’ll end up on Twitter!

Create Website Shortcuts using the Host file

You can also modify the host file to create “shortcuts” that quickly access websites from any program on your computer. For example, if you’re a Twitter addict, you can associate “t” with Twitter – type t in any web browser’s address bar and you’ll instantly end up at Twitter.

You can also create shortcuts with multiple letters, such as twit. You don’t need a .com, .net, .org, or any other type of extension. However, you can’t use spaces.

To do this, just add the following line to the host’s file and save it:

104.244.42.193 t
Create Website Shortcuts using Host file

Now you can type t into any program’s address bar and you’ll end up at twitter.com.

Block websites using host file windows 10

If you want to block your computer from accessing certain websites, you can use the loopback address (127.0.0.1) followed by the domain name (e.g., 127.0.0.1  website.com)

simply add the following entry on the Host file and save.

127.0.0.1    blocksite.com

Ex : 127.0.0.1 facebook.com

127.0.0.1 youtube.com

block websites using host file windows 10

Remove malicious entries set by malware

Also Sometimes Due to Virus / Malware infection you may notice certain Websites not open on your computer. This is Because malware automatically edits your Host file and make Different entries for Domain Redirection (Ex: Any domain Name automatically Redirect to a specific Website ) or Block some websites.

Simply open the Host file on Notepad and Clear Other entries set by Malware adware. And left the default entries as shown below the host file.

Default host file entries

Lock Hosts file to prevent hijacking

As some times malware/ Adware redirect web addresses by altering your host files. A good latest updated antivirus can prevent this hijack but if you want to add another layer of security then the second option is to lock the host’s file so no other program or user except you can rewrite it without unlocking it.

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 Host’s file and prevent anyone or any malware from writing to it.

Lock Hosts file to prevent hijacking

That’s All About edit hosts file on Windows 10. Note that after making any modification on Host files Restart windows to take effect the changes you have done. I hope now you can easily Modify, Edit the hosts file on Windows 10 to Custom Domain Redirection, Block Different Websites, etc. Feel any Difficulty while edit host files discuss in the comments below. Also read:

Comentários


Featured Posts
Recent Posts
Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page