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.
You can also open this file using RUN utility in Windows.
Windows Key + R >> Type “drivers” and Press OK
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,
In Mac machine, the file will be located at the following location.
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
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”.
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).
You will get an similar output as shown in the image below.
The IP address 22.214.171.124 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.
126.96.36.199 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..!