What and where is the hosts file
The hosts file is an IP address-name mapping text file that your computer uses to resolve computer names to network IP addresses before using DNS (Domain Name System). At the very minimum, a name-IP address mapping is simply a line in the hosts file that specifies the IP address of a machine, followed by at least one space, then followed by the name of the machine. You can have one or more IP address-name mappings.
In mosts cases, the hosts file just contains an IP address-name mapping for the computer's loopback address--127.0.0.1 which is mapped to "localhost". In Windows Vista and Windows 7, an additional IPv6 loopback address is added ("::1" followed by a space, then "localhost"). Specifically, the hosts file contains these lines:
::1 localhost #this only shows up in Windows Vista and Windows 7
Notice that you can add comments immediately one space after the host name specification by preceding it with the "#" character.
Say for example you have a media server at home, and you've set it to statically use the IP address 192.168.0.15. In the hosts file, you will need to simply add another line, and in it put:
192.168.0.15 mediaserver #this is my home media server
Once you save the hosts file with this new entry, you can access your media server by name--mediaserver. For example, if it has a web interface and you manage it using Internet Explorer, you simply browse to it using http://mediaserver in the address field of the browser--whereas before, you would use http://192.168.0.15.
Starting from Windows 2000 and all the way to Windows 7, the default location of the hosts file is c:\windows\system32\drivers\etc.