Subject: Re: Multiple IP addresses for a single host in "/etc/hosts"
To: Chris G. Demetriou <cgd@netbsd.org>
From: Luke Mewburn <lukem@goanna.cs.rmit.edu.au>
List: tech-net
Date: 05/31/1999 10:04:14
Chris G. Demetriou writes:
>>> Of course, with /etc/hosts there's an efficiency issue (i.e. it'd be
>>> nice to just fine one match and return, rather than having to scan the
>>> whole file), but that's perhaps best addressed via a (new)
>>> nsswitch.conf option.
>> 
>> Something like "files" vs. "files_multi"?
> 
> That's one possibility, sure.  I suck at picking names, though, and am
> not too familiar with how it 'should' be done in the nsswitch.conf
> world, so i'm quite willing to let somebody else pick the name and
> implementation.  It just seems like the right general direction to
> shoot for.  8-)

I like Matthias' idea of multiple scanning. I'm not sure that it's
necessary to add another `source' to nsswitch to support this. This
functionality, if added, should just be added to the `files' code,
which is what Matthias initially proposed anyway...

As others have pointed out, when you lookup from DNS you may get multiple
addresses, so the only reason for allowing the end-user to specify is
to avoid the `performance' hit of scanning all of /etc/hosts. IMHO, if
/etc/hosts is so large that there's a performance hit, run a local named
(even if it's just a faked up domain), and let named's database engine
do the work for you. /etc/hosts is for safety at boot time...

From (hazy) memory, there is a slight difference between results from
/etc/hosts and DNS anyway:
	- /etc/hosts only returns the first match, but does return
	  a list of aliases (i.e, those supplied on the same line)
	  in h_aliases.
	- DNS returns all matches but generally doesn't return any
	  aliases.

Matthias' proposed change means that the only difference would be
/etc/hosts returns info in h_aliases that a DNS request wouldn't...