Hosts file

From LQWiki
Jump to: navigation, search

The /etc/hosts file maps the IP address of a device connected to the network to a name (typically the devices hostname). Due to the arrival of DNS this file is rarely used but is still useful for small networks and at boot when no name servers are running. In addition, the hosts file can be hacked so that the domain name of servers that host annoying webpage ads are redirect to the loopback address (127.0.0.1). Need link to sample hosts file that does this.

The layout of the file is a simple list of IP addresses followed by the name of the host e.g.:

127.0.0.1 localhost
192.168.1.1 gateway
192.168.1.2 fileserver1
192.168.1.3 foo1
192.168.1.4 foo2

See Also