|Lesson 4||The name service methods |
|Objective||Hosts Files and DNS for Name Service |
Hosts Files and DNS for Name Service
The hosts file
How do I use hosts files and DNS for name service? The first, and simplest, of the name service methods is to save a list of IP addresses and host names in a text file. This method is particularly useful because it is available before any networking configuration has been carried out.
On UNIX machines, the /etc/hosts file is a text file that lists IP addresses in one column and host names in another.
Here is a typical example:
127.0.0.1 localhost localhost.localdomain
126.96.36.199 raphael.acme.com raphael
188.8.131.52 splinter.acme.com splinter
IP Address in file
Each line of this file specifies an IP address, followed by one or more names.
The additional names are aliases, so that, for example, in the above file the names raphael and raphael.acme.com may both be used for the machine with address 184.108.40.206. Some systems use the hosts file for other parts of TCP/IP configuration.
Therefore, your hosts file should always contain the IP address and name of your own machine.
Becoming DNS client and resolv.conf
The second major source of name service is the Internet-wide Domain Name Service.
We will discuss DNS in detail later. For now, suffice it to say that to obtain DNS name service (in other words, to become a DNS client), you must know the IP address of at least one DNS name server. You must also know your own DNS domain name.
The basic configuration information for the DNS part of the resolver library belongs in the /etc/resolv.conf configuration file.
This very simple file need only contain the following information:
domain [your DNS domain]
where IP1, IP2, and IP3 are the IP addresses of DNS servers. You need only supply one
nameserver line, but you may supply up to three. The additional servers are used as backups.
Name Service Method - Quiz