Windows Hosts File – Complete Explanation

W

To speak about “windows hosts file” you must have to know about the term “hosts” in information technology context and how do we connect to a host.

What is a host ?

A host in technology terms can be considered as a node in internet. A node in internet is nothing but a device that is connected to internet. It can be your computer, PDA or it can be a web server that is serving you the pages. Now if you come across terms like network host or web host then probably you can guess by separating the two words and getting meaning out of it.

Host Name to IP address Mapping : How do we connect to a host ?

Every node in internet has unique IP Address, this IP address will be used as an identifier to connect to that particular host. However a  Static IP is different from Public IP and one can connect to only a node which has public IP.

So shortly, to connect to any host in internet we need to have its IP address but it is highly impossible to remember the IP addresses of each host. For example Google.com will be hosted on one host which will have its own unique IP and similarly Facebook.com will be hosted on one other host which will have one more unique IP again. So, rather than remembering the IP address we have created domain names like google.com and facebook.com.

What exactly happens is that, whenever you type a domain name on the address bar  of your browser, a query will be raised to find the IP address of the host attached with the domain name that you have entered in the address bar to a “Domain Name Server”  which will in turn respond with the IP address of the host attached with the domain name. It can be  either an “Authoritative” answer or “Non Authoritative” answer.

Once the destination IP address is known, requests are sent in the form of packets and routers take the job of routing it the appropriate destination IP address.

What is Windows Hosts File ?

Now we know that to connect to any host we need its IP address, Generally when system does not know the IP address of host it queries DNS server but in windows before it querying DNS servers it looks if there is any entry in hosts file.

In general terms we can consider hosts as the phone book which will maintain list of host names along with their IP addresses and operating system first looks in this phone book for the entries before it queries DNS server.

If you want to see hosts file on your windows operating system, check the following paths depending on your OS .

Windows 95/98/Me c:windowshosts
Windows NT/2000/XP Pro c:winntsystem32driversetchosts
Windows XP Home / windows 7 / Windows 8 c:windowssystem32driversetchosts

You must find a file with “hosts” as its file name, it does not contain any extension. You can try opening it with notepad to see its content. Here is a very common example of hosts file

[code]

# Copyright (c) 1993-2009 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

# localhost name resolution is handled within DNS itself.
#    127.0.0.1       localhost
#    ::1             localhost
[/code]

 

Benefiting from Hosts file :

There are many ways that one can use hosts file to his/her benefits.

1. You can define frequently accessed hosts details in the file so that system won’t took long time waiting for DNS server to find its IP address.

2. You can block any unnecessary websites from being opened using hosts file. To know how to do that please read how to use hosts file to block any website?

3. You can create aliases instead of long names for a host name.

4. You can block your system from being connected to any software updates host .

 

Hope you found this information useful.

About the author

pavankumar.p1990
By pavankumar.p1990