How to Block Websites From the Command Line
Most browsers allow you to block certain sites from access in their individual settings and preferences. Unfortunately, blocking a site with Internet Explorer does not necessarily block that site from being accessed with Firefox or Chrome. This can cause problems for parents or network administrators who are attempting to restrict access to certain websites. However, using the command prompt, you can block websites across all Web browsers that might be installed on the computer.
Instructions
-
-
1
Click "Start" in the lower left of your screen. This will open the Start Menu.
-
2
Click "Run" in the right-hand column, and type "cmd" in the Run dialog text field. Press "Enter" on your keyboard to open the command prompt.
-
-
3
Enter the following line in the command prompt:
notepad C:/Windows/System32/drivers/etc/hosts
Press "Enter" on the keyboard. The hosts file will now open in Notepad.
-
4
Locate the following line in the file:
127.0.0.1 localhost
-
5
Retype the number, beginning with 127, under the line where it appears already. Add the website you wish to block after the number. It should look like this:
127.0.0.1 www.BlockedSite.com
-
6
Add any additional sites you want blocked to the list in the same fashion. If you can get to a site using "www" and without it, then add both. It should look like this:
127.0.0.1 www.BlockedSite.com
127.0.0.1 BlockedSite.com
-
7
Save the file, and close Notepad and the command prompt. Those sites listed should now be blocked by all browsers on your computer.
-
1
Tips & Warnings
To unblock a site, remove it from the hosts file.