first /etc/hosts, then nameserver

Chip Old fold at bcpl.net
Tue May 8 16:00:17 UTC 2001


On Tue, 8 May 2001, felix wrote:

> I want my solaris-box to lookup namequeries (that machine has no local
> dns-server) first in /etc/hosts then send the query to each nameserver
> in /etc/resolv.conf, but how to??

In /etc/nsswitch.conf look for the line beginning with "hosts".  It should
look something like this:

hosts:      files dns

/etc/nsswitch.conf determines the order in which the different name
services available to the machine will be tried.  The example above causes
hosts to be looked up in /etc/inet/hosts first.  If not found there, they
are looked up in DNS.

If you also use NIS, then that needs to be included as well:

hosts:      files nis dns

Just list the available name services in the desired search order.
The example above means /etc/inet/hosts will be tried first, then NIS,
then DNS.

By the way, it's not a good idea to list DNS *before* the hosts file, like
this:

hosts:      dns files

In that configuration, if for some reason DNS isn't available, it can
cause your Solaris box to fail at boot (or at least take a LONG time to
boot) because it can't discover its own name unless/until the search fails
over to the hosts file.  Always list "files" first, and make sure the
machine's name and address are in /etc/inet/hosts.  This may seem like a
silly unnecessary warning, but I've had to deal with the consequences a
number of times when a local admin has put "files" after "dns" (or even
deleted "files") in /etc/inet/hosts.

-- 
Chip Old (Francis E. Old)               E-Mail:  fold at bcpl.net
Manager, BCPL Network Services          Voice:   410-887-6180
Manager, BCPL.NET Internet Services     FAX:     410-887-2091
320 York Road
Towson, Maryland 21204-5179 U.S.A.



More information about the bind-users mailing list