Академический Документы
Профессиональный Документы
Культура Документы
July 13
o The /etc/hosts file is used to associate a computer name with an IP address. Used
to speed up the IP address lookup of frequently requested addresses.
The default contents of the file look similar to this:
127.0.0.1 localhost.localdomain localhost
192.168.208.17 teacher
The loopback device is assigned a name of localhost.localdomain
or localhost. The computer with an IP address of 192.168.208.17
is assigned a name of teacher.
o Since there are billions of IP addresses in the world, we can’t possibly type in an
entry into out /etc/hosts file for every IP address in the world. Therefore, we need
to be able to connect to DNS servers to find IP addresses. The domain name
server (DNS) contains a big database of computer names that are associated with
IP addresses.
o The /etc/host.conf file specifies whether the local /etc/host file or a DNS server
will be searched first when looking up a computer name. Below is a sample of
what this file might look like.
order hosts, bind
Due to the contents of this file, the system will look up computer names
first in the /etc/hosts file, and then look up the DNS Server.
By the way, bind is the name of the most popular DNS program in Linux.
BIND stands for Berkeley Internet Name Domain.
Name Resolution Example:
/etc/hosts /etc/resolv.conf
127.0.0.1 localhost nameserver 192.168.10.25
192.168.208.1 comp1 nameserver 192.168.10.33
192.168.208.2 comp2
DNS listings at 192.168.208.25
192.168.208.3 comp3
/etc/host.conf 192.168.208.4 comp4
order hosts, bind
Here’s an example. Assume that you enter the following command: ping comp27
o Your system will look first at its /etc/host.conf file to see where it should look
first. Looking at the file above, it will look at the /etc/hosts file first.
o There is no listing for comp27 in the /etc/hosts file. Therefore, your system will
have to look at the /etc/resolv.conf file in order to find a DNS.
o The first DNS is located at 192.168.208.25. Your computer will then send a
request to search the listings at this DNS. However, there is no listing for comp27
here.
o The next DNS is located at 192.168.208.33. Therefore, your computer will then
send a request to search the listings at this DNS. There is a listing for comp27
here and the IP address, 192.168.208.27, is returned.