Select Page

Blocking websites in your PC – No software required

Do you want to block any websites in your PC ? Here is the simple way that don’t need any Antivirus, firewall or any other software.

HOW TO DO?

In every PC, it may be Windows, Linux or Mac, there will be a file called HOSTS. We are going to use this file to block or redirect the websites somewhere.

WHAT IS A HOSTS FILE?

Like any other file in your system, hosts is a file used by the Operating system. It is used to map a hostname or website to an IP address.

In other words, when you type “www.facebook.com” in your browser, your computer will check the hosts file to see if there is any IP address defined for that hostname (www.facebook.com). If there is no entry found for the hostname (www.facebook.com), then the computer will request the IP address of www.facebook.com to DNS (Domain Name System) servers.

In most of the case, this hosts files will not have any manual configuration in it. So, every time when you browse any website, your computer will ask DNS servers for the IP address. This method of defining IP address for a website or hostname is called as LOCAL DNS method.

WHERE IS THE HOSTS FILE LOCATED?

In Windows, the file will be located at the following location.

C:\Windows\System32\drivers\etc\hosts

hosts

You can also open this file using RUN utility in Windows.

Windows Key + R  >> Type “drivers” and Press OK

drivers

It will take you to the ‘Drivers’ folder where you can see the folder called ‘etc’.Hosts will be inside that ‘etc’ folder.

In Linux machine, open terminal and the file will be located at,

/etc/hosts

In Mac machine, the file will be located at the following location.

/private/etc/hosts

In Windows, you can edit this file by opening in Notepad, Notepad++, Wordpad or any other text editors. In the same way you can edit this file in Linux and Mac using any editors like vim, nano etc.,

WHAT TO DO NOW?

Just open this hosts file as Administrator and enter the following at the end of the file to block www.facebook.com.

127.0.0.1 facebook.com www.facebook.com

notepad

Now Save this file. Please note that, you need administrator privilege to save this file. Now try accessing facebook.com or www.facebook.com in any browser in your system. You will get the error that “The webpage is not available”.

not availableLike this, you can block any number of websites in your PC. All you have to do is, enter the website name as given below in the hosts file.

127.0.0.1 website1.com www.website1.com
127.0.0.2 website2.com www.website2.com

 How redirect a website?

 If you don’t want to block the site and you wish to redirect the website to another site, you can use this method. Let me explain in detail. If you want to redirect facebook.com to Google.com, the entries in the hosts file should be modified little. Very little. 

To redirect facebook.com to Google.com, we need the IP address of Google.com. You can get the IP address of google.com using a simple command called ping.

Just execute the following command in command prompt (Windows) or terminal (Linux and Mac).

ping google.com

You will get an similar output as shown in the image below.

ping

The IP address 74.125.235.70 which is marked in yellow colour is the IP address of google.com.

Now paste the following entry in hosts file to redirect facebook.com to google.com.

74.125.235.70 facebook.com www.facebook.com

That’s it. It is done. Now try accessing facebook.com in your browser. You can see it redirecting to google.com. Likewise, you can redirect any website to any other website. Also, you can block any website. No need of firewall, antivirus or any other software.

Hope you enjoyed this post..!

About The Author

It's me, Nivas Baskaran , a product of the 90's living in Bangalore. This is my personal blog and I'm here to post some cool stuffs. I love spending time with my Friends. Jovial in nature. I love Tea/Coffees. Ping me to know more about me :P

Leave a reply

Your email address will not be published. Required fields are marked *


Subscribe for Updates

Like Us on Facebook

Categories