DNS and BIND
Client Configuration
For client configuration there are four important files: /etc/hosts
, /etc/host.conf
, /etc/nsswitch.conf
, and
/etc/resolv.conf
.
/etc/hosts
The following is an example /etc/hosts
file:
127.0.0.1 localhost.localdomain localhost testmachine ::1 localhost6.localdomain6 localhost6
The syntax is as follows: IP address, Fully Qualified Domain Name (FQDN), aliases or hostnames.A localhost entry is required otherwise applications will break. The second line is for IPv6, which will not be covered in this guide. Using this example, the ping localhost
and ping testmachine
commands will be the same as using the ping 127.0.0.1
command.
/etc/host.conf
The following is an example /etc/host.conf
file:
order hosts,bind multi on nospoof on
The order
section defines the order the resolver library will use. In this case the resolver will first query the local hosts file, /etc/hosts
, and then a DNS server. The multi on
option allows a machine in /etc/hosts
to have multiple IP addresses, which is useful for systems with more than one network interface. Use the nospoof on
option to help prevent IP spoofing.
/etc/nsswitch.conf
On systems running the GNU version 2 of the standard library, glibc, the /etc/nsswitch.conf
file takes precedence over /etc/host.conf
. If you are running glibc ignore the /etc/host.conf
file. For DNS configuration the most important entry in /etc/nsswitch.conf
is the hosts entry:
hosts: files dns
This defines the order the resolver will use. Using this example, the resolver will first query the local hosts file (files
). If the query can not be resolved using the information in /etc/hosts
, a DNS server is queried (dns
). If the /etc/hosts
file only contained an entry for localhost, a DNS server would be used for all queries other than those for localhost.
hosts order |
Do not remove files from the hosts section of /etc/nsswitch.conf . This will cause applications to break and queries to fail if the DNS server becomes unavailable.
|
/etc/resolv.conf
The /etc/resolv.conf
file is used to list the IP addresses of nameservers to use for DNS queries. This nameservers listed will be used to resolve all queries that can not be resolved using the /etc/hosts
file. The following is an example /etc/resolv.conf
file:
domain testdomain.com nameserver 192.168.0.1 nameserver 192.168.0.2
Currently you are allowed to have 3 nameserver
directives. List these in order of preference. If queries timeout using the first nameserver, the query is attempted again using the second nameserver, and so on.
The domain
directive is used to specify a default domain name to append to queries. If DNS fails to lookup a name, the default domain is appended. For example, if a query for testhost fails, the domain
entry will be appended, in this example resulting in a query for testhost.testdomain.com. The search
directive is similar to the domain
directive. The domain
directive specifies one default domain, whereas search
allows you to specify many. The following is an example of the search
directive:
search testdomain1.com search testdomain2.com search testdomain3.com
If a query for testhost.testdomain1.com timed out, a query for testhost.testdomain2.com would be attempted. If this timed out, a query for testhost.testdomain3.com would be attempted.
Administration Guide - TOC | Previous Page - Introduction | Next Page - Installing BIND |