Sunday, November 12, 2006

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:
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.


Still confused? Have more queries?

If you are having more doubts, please feel free to leave a comment ....

4 comments:

Anonymous said...

could you please send me some proxy site IP's so that i can bypass my company firewall???

please send it across to srss4u@yahoo.com or reply to this comment...

Thanks in Advamce,
Rahul

Arun Prabhakar said...

You can bypass firewall by
Host Name : cooltunnel.com
IP Address : 72.232.123.170

You can find 100's of anonymous HTTP proxy servers, just do a google search.

You can also use google's translate facility to by pass the firewall. Just goto translate.google.com
and do a translation to english of the site you want to visit.

PS: Wipro?

Arun Prabhakar said...

In case the above methods don't work ...
kproxy.com
62.193.235.46

Try also ...

+ wtunnel.com
+ ctunnel.com

(thanx sreejith)

Anonymous said...

if on a single ip address there are more domains

for example
mysite.domain.com has ip1

if i put ip1 www.google.com

putting google.com will redirect me to ip1 but not to my site

how ca you do that ?