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 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:
# # source server
# # x client host localhost

The Lines followed by a # are comments and explains how to use the HOSTS file. 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

What now ?

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

Now what happens is whenever you try to visit "" 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
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 :  # google server ip

Now visiting "" takes you yo "".

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). subdomain.localhost

Oops I screwed up ...

Restore the backup file if u have already done so
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 ....


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 or reply to this comment...

Thanks in Advamce,

Arun Prabhakar said...

You can bypass firewall by
Host Name :
IP Address :

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

Try also ...


(thanx sreejith)

Anonymous said...

if on a single ip address there are more domains

for example has ip1

if i put ip1

putting will redirect me to ip1 but not to my site

how ca you do that ?