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 www.google.com, open HOSTS file using notepad and add " 127.0.0.1 www.google.com " without double quotes at the end of the line. Save the HOSTS file and open your favorite browser and type " www.google.com " 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. " 127.0.0.1 " 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 www.google.com " 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 www.google.co.in using PING in DOS window and type <IP address of Google> www.bing.com
It should look like " 74.125.236.48 www.bing.com " without double quotes. Here 74.125.236.48 is the IP address of www.google.co.in
Now when you type www.bing.com in the address bar of the browser it will direct to www.google.co.in
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.

2 comments:

  1. Vеry rapidly this web site ωill be famоuѕ amid all blog реople, duе to it's good articles or reviews
    My site :: forward

    ReplyDelete
  2. Appreciation to my father who shared with me on the topic of this website, this website is truly
    awesome.

    My blog post - internet bookmakers

    ReplyDelete

Google Analytics