The "hosts" file

If you have a small local network, or if you just want to map a few domain names to different IP numbers1), the hosts file feature available on most modern Operating Systems saves you the bother of running a complete DNS server. Using hosts instead of DNS can safe you time if you have a relatively small and static network, though it is not as scalable and doesn’t have as much applications as setting up a local DNS zone.

The hosts file is just a small text file, where each line contains an IP number, followed by some domain names for that IP number. Lines with # are comments. For example:

127.0.0.1      localhost www.mytestdomain.com
192.168.101    athlon.localnet

The hosts file is local to a specific PC, so you will need one on any PC on which you want this. This is the reason that if you have multiple PCs and regularly changing IP numbers or domain names, you are probably better of running a DNS server – and Posadis.org happens to server a quite fine DNS server :)

Location of the hosts file

hosts files are supported by all Unices, Windows, and Mac OS. For Unix (and probably Mac OS X, too), the location of the file is /etc/hosts. For Windows, the location of the file tends to change between different versions (info from here):

Windows version File location
Windows 95/98/Me c:\windows\hosts
Windows NT/2000/XP Pro c:\winnt\system32\drivers\etc\hosts
Windows XP Home c:\windows\system32\drivers\etc\hosts

For Macintosh, it should be somewhere in the “Preferences” subfolder of the System folder.

References

1) This is commonly done with domain names of, for example, doubleclick.net to block ads.
 
  dns/hosts.txt · Last modified: 2005/01/30 06:07
 
Copyright © Meilof Veeningen, 2002-2005 - About Posadis.org