Книга: Fedora™ Unleashed, 2008 edition

The /etc/hosts File

The /etc/hosts File

The file /etc/hosts contains a table of local hosts (hostnames and IP addresses) used for local DNS-type lookups. The file is used if the keyword hosts is included in the order line of /etc/host.conf.

Using /etc/hosts to provide hostnames and hostname aliases can be effective when used on small networks. For example, a short /etc/hosts might look like this:

...
192.168.0.3 teletran.hudson.com teletran webserver #always breaks
192.168.0.4 optimus.hudson.com  optimus mailserver
192.168.0.5 prowl.hudson.com    prowl music repository
192.168.0.6 megatron.hudson.com fileserver
...

This example shows a short list of hosts. The format of the file is an IP address, a host name/domain name, and aliases (such as teletran and optimus). Using this approach, a system administrator would maintain and update a master hosts list, and then replicate the complete /etc/hosts file to every computer on the LAN. Users are then able to access other systems by simply using the hostname alias (such as teletran). The format of /etc/hosts is easy to understand and easy to maintain, and can be used in conjunction with DNS, and in conjunction with a Dynamic Host Configuration Protocol (DHCP) server on the same network.

Two disadvantages of using /etc/hosts become readily apparent on a large network: maintenance and replication. Maintaining huge lists of IP addresses, hostnames, and aliases — along with ensuring that changes are regularly updated to every host on the network — can be a challenge.

The /etc/hosts file can be edited with a text editor or with the system-config-network GUI configuration tool, which can be launched by going to System, Administration and choosing Network. Choose the Hosts tab to edit the file.

Оглавление книги


Генерация: 0.048. Запросов К БД/Cache: 0 / 0
поделиться
Вверх Вниз