Linux Networking/Configuring your Name Resolver< Linux Networking
The `Name Resolver' is a part of the linux standard library. Its prime function is to provide a service to convert human-friendly hostnames like `ftp.funet.fi' into machine friendly IP addresses such as 22.214.171.124.
What's in a name ?Edit
You will probably be familiar with the appearance of Internet host names, but may not understand how they are constructed, or deconstructed. Internet domain names are hierarchical in nature, that is, they have a tree-like structure. A `domain' is a family, or group of names. A `domain' may be broken down into `subdomain'. A `toplevel domain' is a domain that is not a subdomain. The Top Level Domains are specified in RFC-920. Some examples of the most common top level domains are:
COM Commercial Organizations
EDU Educational Organizations
GOV Government Organizations
MIL Military Organizations
ORG Other organizations
NET Internet-Related Organizations
Country Designator these are two letters codes that represent a particular country.
For historical reasons most domains belonging to one of the non- country based top level domains were used by organizations within the United States, although the United States also has its own country code `.us'. This is not true any more for .com and .org domains, which are commonly used by non-us companies.
Each of these top level domains has subdomains. The top level domains based on country name are often next broken down into subdomains based on the com, edu, gov, mil and org domains. So for example you end up with: com.au and gov.au for commercial and government organizations in Australia; note that this is not a general rule, as actual policies depend on the naming authority for each domain.
The next level of division usually represents the name of the organization. Further subdomains vary in nature, often the next level of subdomain is based on the departmental structure of the organization but it may be based on any criterion considered reasonable and meaningful by the network administrators for the organization.
The very left-most portion of the name is always the unique name assigned to the host machine and is called the `hostname', the portion of the name to the right of the hostname is called the `domainname' and the complete name is called the `Fully Qualified Domain Name'.
To use Terry's host as an example, the fully qualified domain name is `perf.no.itg.telstra.com.au'. This means that the host name is `perf' and the domain name is `no.itg.telstra.com.au'. The domain name is based on a top level domain based on his country, Australia and as his email address belongs to a commercial organization, `.com' is there as the next level domain. The name of the company is (was) `telstra' and their internal naming structure is based on organizational structure, in this case the machine belongs to the Information Technology Group, Network Operations section.
Usually, the names are fairly shorter; for example, my ISP is called ``systemy.it and my non-profit organization is called ``linux.it, without any com and org subdomain, so that my own host is just called ``morgana.systemy.it and email@example.com is a valid email address. Note that the owner of a domain has the rights to register hostnames as well as subdomains; for example, the LUG I belong to uses the domain pluto.linux.it, because the owners of linux.it agreed to open a subdomain for the LUG.
What information you will need.Edit
You will need to know what domain your hosts name will belong to. The name resolver software provides this name translation service by making requests to a `Domain Name Server', so you will need to know the IP address of a local nameserver that you can use.
There are three files you need to edit, I'll cover each of these in turn.
The /etc/resolv.conf is the main configuration file for the name resolver code. Its format is quite simple. It is a text file with one keyword per line. There are three keywords typically used, they are:
domain this keyword specifies the local domain name.
search this keyword specifies a list of alternate domain names to search for a hostname
nameserver this keyword, which may be used many times, specifies an IP address of a domain name server to query when resolving names
An example /etc/resolv.conf might look something like:
domain maths.wu.edu.au search maths.wu.edu.au wu.edu.au nameserver 192.168.10.1 nameserver 192.168.12.1
This example specifies that the default domain name to append to unqualified names (ie hostnames supplied without a domain) is maths.wu.edu.au and that if the host is not found in that domain to also try the wu.edu.au domain directly. Two nameservers entry are supplied, each of which may be called upon by the name resolver code to resolve the name.
The /etc/host.conf file is where you configure some items that govern the behaviour of the name resolver code. The format of this file is described in detail in the `resolv+' man page. In nearly all circumstances the following example will work for you:
order hosts,bind multi on
This configuration tells the name resolver to check the /etc/hosts file before attempting to query a nameserver and to return all valid addresses for a host found in the /etc/hosts file instead of just the first.
The /etc/hosts file is where you put the name and IP address of local hosts. If you place a host in this file then you do not need to query the domain name server to get its IP Address. The disadvantage of doing this is that you must keep this file up to date yourself if the IP address for that host changes. In a well managed system the only hostnames that usually appear in this file are an entry for the loopback interface and the local hosts name.
# /etc/hosts 127.0.0.1 localhost loopback 192.168.0.1 this.host.name
You may specify more than one host name per line as demonstrated by the first entry, which is a standard entry for the loopback interface.
Running a name serverEdit
If you want to run a local nameserver, you can do it easily. Please refer to the DNS-HOWTO and to any documents included in your version of BIND (Berkeley Internet Name Domain).