Thursday, September 25, 2008

About "HOSTS" File

Warning: Backup the file before playing with it!

What does this file do?

The HOSTS file found on Windows (and linux too) is like a local DNS (domain name server). When you type a url on the browsers address bar, the domain name is converted to the IP of the server by a DNS lookup by the browser. Now here is the catch ... Windows first looks at the HOSTS file before doing any DNS lookup. So we can block certain sites by editing the HOSTS file.


Where is it ? I dont see the HOSTS file

HOSTS file is found typically here ...
Windows XP : C:\WINDOWS\SYSTEM32\DRIVERS\ETC
Windows 2K : C:\WINNT\SYSTEM32\DRIVERS\ETC
Windows 98/ME : C:\WINDOWS

Linux : /etc/



What is in this FILE?

HOSTS file is just a plain text file. So you can use any text editing software like notepad to edit the contents of the file.
Typical content of a HOSTS file is shown below :

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost

The Lines followed by a # are comments and explains how to use the HOSTS file. 127.0.0.1 is the IP address that is used to loopback to your computer itself. So if you are running an apache or IIS server or anyother server software, you can access it by the url http://localhost or http://127.0.0.1

What now ?

Suppose you want to block some sites for example say you want to block "www.sicksite.com". All you have to do is add another line to the HOSTS file:
127.0.0.1 www.sicksite.com

Now what happens is whenever you try to visit "www.sicksite.com" it goes to the site on your localhost. For common people those who dont run any server, localhost is nowhere!


Why would i want to block sites ?

There are many parasitic servers out there on the internet, that track your movements while browsing. So if you want to protect yourself, include those sites on the HOSTS file.

A list of sites that is parasitic or is an ad serving site is given in
http://www.mvps.org/winhelp2002/hosts.txt
It is not recommended to copy the entire list to your local HOSTS file as it slows down the system. So choose ones that you think needs to be blocked.


What is this pop up about?

When you are saving the HOSTS file, a pop up may appear that asks you to confirm the changes to the HOSTS file. This pop up may or may not appear based on the OS, and other Anti-Virus Softwares you are running.


What else can I do with "HOSTS" file?

You can also make a site point to another site. By making an entry as follows :
72.14.207.99 www.mysearchengine.com #72.14.207.99 google server ip

Now visiting "www.mysearchengine.com" takes you yo "www.google.com".

To find out IP address of sites visit:

• http://www.hcidata.co.uk/host2ip.htm

• http://cqcounter.com/whois/

If your are a webmaster, HOSTS file allows you to make subdomains within localhost (depends on server software and after configurations in it).

127.0.0.1 subdomain.localhost



Oops I screwed up ...

Restore the backup file if u have already done so
OR
Copy the sample HOSTS given above and save it.

1 comment:

Anonymous said...

My friend and I were recently talking about the prevalence of technology in our day to day lives. Reading this post makes me think back to that debate we had, and just how inseparable from electronics we have all become.


I don't mean this in a bad way, of course! Ethical concerns aside... I just hope that as memory gets cheaper, the possibility of downloading our memories onto a digital medium becomes a true reality. It's a fantasy that I daydream about all the time.


(Posted on Nintendo DS running [url=http://knol.google.com/k/anonymous/-/9v7ff0hnkzef/1]R4i SDHC[/url] DS SKu2)

DISCLAIMER

WE USE LINKS TO SITES AND NOT DIRECT DOWNLOAD LINKS. THERE NO FILES HOSTED ON OUR SERVER,THEY ARE ONLY INDEXED MUCH LIKE GOOGLEWORKS.
The hosting server or the administrator cannot be held responsible for the contents of any linked sites or any link contained in a linked site, or changes / updates to such sites.

BY ENTERING THIS SITE YOU AGREE TO BE BOUND BY THESE CONDITIONS
If you don't like the software posted here, please don't hesitate to let us know and we will unpost it.