Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Jul 2004 21:44:46 -0700
From:      Kevin Stevens <freebsd@pursued-with.net>
To:        David Fuchs <david@davidfuchs.ca>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: [Fwd: /etc/hosts and /etc/host.conf confusion]
Message-ID:  <B5AD052E-CCAB-11D8-8439-000A959CEE6A@pursued-with.net>
In-Reply-To: <40E62A8C.1040908@davidfuchs.ca>
References:  <40E62A8C.1040908@davidfuchs.ca>

next in thread | previous in thread | raw e-mail | index | archive | help

On Jul 2, 2004, at 20:39, David Fuchs wrote:

> # $FreeBSD: src/etc/host.conf,v 1.6 1999/08/27 23:23:41 peter Exp $
> # First try the /etc/hosts file
> hosts
> # Now try the nameserver next.
> bind
> # If you have YP/NIS configured, uncomment the next line
> # nis

That's typical.

> 	Considering that 'hosts' is listed first, I would expect that any 
> entries I add to /etc/hosts will take precedence over entries 
> retrieved from bind.  So, I added an entry to this file for a random 
> IP-to-name mapping, and tested it with the 'host(1)' command, and it 
> failed.  When I enable debugging, it clearly shows that it's 
> consulting the first nameserver listed in resolv.conf (an external 
> host), no mention of a hosts file anywhere (or attempt to send a 
> request to the local host)

Try ping; even if the host isn't available you can see if it resolves.  
"host" does it's own thing, which is sometimes non-obvious (to me at 
least).  Look at the sections in man host about the variables it 
expects to be configured.

> Additionally, what classifies as 'when the name server is not running' 
> - does this mean that /etc/hosts is used when all the nameservers 
> listed in /etc/resolv.conf are unavailable? (As I only use the local 
> named(8) daemon to host my personal domain, not for everyday recursive 
> lookups.)  Or does it literally refer to when my local copy of 
> named(8) is not in the process list?

The latter.  For example, many workstations aren't configured to run 
named at all; they'll still reference their local hosts file.

KeS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B5AD052E-CCAB-11D8-8439-000A959CEE6A>