cache-only named won't resolve "localhost"

Chuck Swiger cswiger at
Tue Aug 16 01:49:45 GMT 2005

Gary W. Swearingen wrote:
[ ... ]
> so I'd think domain resolution should look in /etc/hosts before
> even checking my cache-only named.  Which it seems to do for "ping",
> but not for "host", "nslookup", or "mozilla".

As Lowell noted, programs like "nslookup" and "dig" are designed to query DNS 
specificly, not look into your flatfiles for hostname/IP mappings.

> I'm still wondering if I should be declaring a forward zone for
> "localhost" or "localhost.localhost"; it seems kinda strange that
> the script would set up a reverse for it, but say nothing about
> the forward.

Note that the resolver will treat lookups of "localhost." and "localhost" 
differently if you have a domain or search directive specified in 
/etc/resolv.conf.  You could and perhaps should ensure that the one ending in a 
period exists in a zone file on the nameserver, and maps via an A record to

; BIND data file for local loopback interface

$TTL 604800

@       IN      SOA     localhost. root.localhost. (
                               1         ; Serial
                          604800         ; Refresh
                           86400         ; Retry
                         2419200         ; Expire
                          604800 )       ; Default TTL
@       IN      NS      localhost.
@       IN      A


I inherited this from somewhere, you could remove all but the first "IN" (it 
defaults), as well as being less clever about reusing @, but add salt as 
needed. :-)

It is probably also a reasonable idea to have an A record for localhost in each 
forward zone file, so that "" resolves immediately and 
stops rather than querying names throughout the search list of domains.  This 
can reduce annoying DNS delays significantly in a number of circumstances, not 
the least of which are client machines with less-than-brillant resolver 
routines (think WinNT 4).

Oh, yeah, this all was prompted by the notion that some other programs, such as 
squid in particular, also use their own resolver routines like "nslookup" does. 
  But Mozilla ought to pay attention to /etc/hosts.  The connection between 
these two is that you could uncouple mozilla from doing it's own DNS by 
pointing at a proxy server for testing what is going on....


More information about the freebsd-questions mailing list