Subject: Re: defining 'localhost' (was: CVS commit: src/usr.sbin/ntp/ntptrace)
To: Matthias Scheler <>
From: Greg A. Woods <>
List: current-users
Date: 12/31/2003 04:30:55
[ On Monday, December 29, 2003 at 16:51:31 (+0000), Matthias Scheler wrote: ]
> Subject: Re: CVS commit: src/usr.sbin/ntp/ntptrace
> In article <>,
> 	Frederick Bruckman <> writes:
> > Ah. I don't get that error because I have localhost in my nameserver:
> > 
> >   # host localhost
> > has address
> > has address ::1
> > 
> > but that's a hack, too.
> No, it's actually a recommendation in some RFC - don't ask me for the number.

Well, yes, but the recommendation is that it should _not_ be done quite
like Frederick shows above.

See the end for a pointer to a complete ready-to-use solution, and/or
read on for more detailed explanation.

All you really need to provide DNS for your loopback address is a
"localhost" zone that contains at minimum the following three records:

	localhost.              IN      SOA     localhost. hostmaster.localhost. (
	                        2003073113      ;serial number (version)
	                        28800   ;slave refresh period (8 hours)
	                        7200    ;slave retry interval (2 hours)
	                        14515200        ;slave expire time (24 weeks)
	                        57600   ;negative response TTL (16 hours)
	localhost.              IN      NS      localhost.
	localhost.              IN      A

This is as per RFC 1912, which is really just an informational document.
(note that BCP 32, aka RFC 2606, does reserve the TLD "localhost")

You may want a "localhost.mydomain.example" CNAME to get around bugs in
the many programs that think they're smarter than they actually are.
For example I have:    IN      CNAME   localhost.

However as per the discussion in RFC 1912 you don't really want to
include your local domain name on the actual hostname pointing to the
loopback address.

You might also want this one for IPv6 support:

	localhost.              IN      AAAA    ::1

And for helping out netstat and similar tools with RFC 1101 compatible
names you'll want these records as well:

	  loopback-net.localhost. 	IN      A

	loopback-bcast.localhost.       IN      A

You'll probably also want a corresponding reverse zone too (or three
zones if you want zone cuts at all the octet levels as I do): IN      NS      localhost. IN      NS      localhost. IN      NS      localhost. IN      PTR     localhost.

and for the RFC 1101 names: IN      A IN      PTR     loopback-net.localhost.       IN      NS      localhost.       IN      NS      localhost.       IN      PTR     loopback-bcast.localhost.

There are some other "local" zones that you should have too (also
documented in RFC 1912), and then there are the tricks to speed up
queries for RFC 1918 related records....

A complete set of BIND config and zone files providing these and the
other basic zones needed for building a "turn-key" local caching server
can be found here:

						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <>
Planix, Inc. <>          Secrets of the Weird <>