Wednesday, June 15, 2011

Block certain sites or mapping of IP addresses to host names using HOSTS file

HOSTS file contains mappings of IP addresses to host names. The HOSTS file does not have any extension. It is just names as “ hosts ”. Some computers running Windows operating system does contain HOSTS file. Instead those computers will have a file called “ hosts.sam ”, meaning sample file containing mappings of IP addresses to host names.
You can open the HOSTS file in any text edit such as NOTEPAD and make the changes.

If you want to block certain sites, for example to block, open HOSTS file using notepad and add " " without double quotes at the end of the line. Save the HOSTS file and open your favorite browser and type " " in address bar. Now you can see the message " Page cannot be found ".  If you are still able to browse the Google page then restart the computer and again open the Google website in web browser. " " is the loopback IP address also called as local address pointing to you own computer. In the above example you are directing IP address of the Google to your computer
To find the IP address of the website, go to START and click on RUN or hold the WINDOWS key and press R to open RUN window. Type " cmd " and press ENTER key to open DOS window. Now type
" ping " without double quotes to ping Google website to find the IP address.
You can increase the internet surfing speed by mapping IP addresses to host names. Usually IP addresses to host names resolving is done by DNS (Domain Naming Servers). Some times it takes time to resolve IP addresses to host names using DNS. If that is the case, then you can use HOSTS file to map IP addresses to host names. For example, if you want to map BING website to Google website IP address then get the IP address of using PING in DOS window and type <IP address of Google>
It should look like " " without double quotes. Here is the IP address of
Now when you type in the address bar of the browser it will direct to
But remember the HOSTS file size is limited. You cannot add a big list to block or map the websites.

In Windows/95/98/ME, HOSTS file is located at C:\WINDOWS\HOSTS
In Windows NT/2000, HOSTS file is located at C:\WINNT\SYSTEM32\DRIVERS\ETC\HOSTS
In WindowsXP Home/Pro , HOSTS file is located at C:\WINDOWS\SYSTEM32\DRIVERS\ETC\HOSTS

NOTE: Always remember to take backup of your original HOSTS file before making changes to it.

Google Analytics