TCP/IP Configuration  «Prev  Next»

Lesson 4The name service methods
ObjectiveHosts 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: localhost localhost.localdomain raphael 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 may both be used for the machine with address 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]
nameserver IP1
nameserver IP2
nameserver IP3

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

Click the Quiz link below to take a short multiple-choice quiz on name service methods.
Name Service Method - Quiz

TCP/IP Illustration