Block websites on your computer

Block websites on your computer :
Press WIN+R
and type this %windir%\system32\drivers
\etc
or navigate to C:\Windows\System32\drive
rs\etc
and now you will see the hosts file
Now open notepad from start menu by typing notepad and running it as an administrator.
Open the hosts file by navigating to C:\Windows\System32\drive
rs\etc.
Now if you want to block site say facebook and google then type these lines(Marked in red rectangle)
The next time you open google or facebook it will not open.(Note:This trick will work if your browser is not open.If your browser is open close the browser and restart it.)
Using this property you can do website redirecting . For example if someone wants to open facebook but you want them to be redirected to google. First we need to know the ip address of Google . To do that open cmd and type tracert google.com in cmd and note down the ip address of Google as shown in the pic
Now Google ip address is 216.58.220.46 . hence I will be typing this in notepad
Now the next time you try to open facebook you will be redirected to google.
To unblock websites open the hosts file in notepad and delete those lines
For linux users :
Open terminal and type these lines,
First create a backup of the hosts file given below :
  1. sudo cp /etc/hosts /etc/hosts.bak
Suppose you want to block google website then type this
  1. sudo sh -c 'echo "0.0.0.0 Google">>/etc/hosts'
or type this
  1. sudo sh -c 'echo "127.0.0.1 Google">>/etc/hosts'
Just replace google with any other website to block that website
To unblock websites type this
  1. sudo cat /etc/hosts.bak>/etc/hosts

Comments