I see on wikipedia that a host file maps IP addresses to human-readable hostnames, much like a DNS server. But does a local computer need to resolve IP addresses? Is the idea that you configure the hosts file for all of the computers on a network so as to customize/configure the network? (Kind of like for a local machine name in windows).
See the manpage of the hosts file, there are some interessting parts.
man hosts ... Historical Notes RFC 952 gave the original format for the host table, though it has since changed. Before the advent of DNS, the host table was the only way of resolving hostnames on the fledgling Internet. Indeed, this file could be created from the official host data base maintained at the Network Information Control Center (NIC), though local changes were often required to bring it up to date regarding unofficial aliases and/or unknown hosts. The NIC no longer maintains the hosts.txt files, though looking around at the time of writing (circa 2000), there are historical hosts.txt files on the WWW. I just found three, from 92, 94, and 95. ...
The file is read before a DNS or any other lookup is made (order defined in
/etc/nsswitch.conf). Is is also needed to map the hostname and the
localhost to the loopback address (127.0.0.1).
One can summarize it as follows:
It is a burden of the last computer decade, but still usefull.
Chaos's answer is perfectly accurate, but there are a couple additional use case which I felt worthy of mentioning.
Aside from containing
localhost, it's also a generally good idea to put the machine's hostname in the file as well. This is so that connecting to the local machine via it's hostname is fast and doesn't need a trip out to the network. Some programs can do this operation a lot, and so the performance is highly beneficial.
Another use case is for fault tolerance. Whenever I build clusters I always put entries for all machines in the cluster in each machine's
hosts file. This is so that if there's some sort of network connectivity issue or DNS failure, the nodes in the cluster will still be able to communicate with eachother.