What about this solution

Alex Zbyslaw xfb52 at dial.pipex.com
Fri Feb 17 11:22:41 PST 2006

Giorgos Keramidas wrote:

>On 2006-02-17 11:59, David Banning <david+dated+1140627600.cba43d at skytracker.ca> wrote:
>>I just put
>>        banning.ca
>>in my /etc/hosts and it solved the problem.
>>Can I have multiple lines, each line with the same IP number in
>>/etc/hosts, with different virtual hosts on the right?
>I think it's ok to have multiple lines, but I'm not sure.
I think it works, but I don't think it's what the man page says and 
personally I wouldn't rely on it.  I don't know if there is any line 
length limit, which matters if you have 50 or 60 host names on the 
line.  Again the man page doesn't *say* there is a limit, but without 
checking source code I wouldn't bet on anything.  My longest line is 247 
chars without issues I have seen.

 From man 5 hosts

>      For each host a single line should be present with the following 
> informa-
>      tion:
>            Internet address
>            official host name
>            aliases

It's not clear to me what that means.  If it means "for each official 
host name", then IP lines should be duplicatable.  If it means "For each 
IP address" then multiple lines should not be used.

FWIW, a Linux distro says:

> This file
>        is a simple text file that associates IP addresses with 
> hostnames,  one
>        line per IP address

but actually seems to work fine with multiple lines with the same IP 
address.  Go figure.

>If that solves your immediate problem, then that's ok :)
I didn't follow the thread that closely, but I understood that the wrong 
IP ( was apparently being returned for a host name that should 
have had proper IP.  Personally, I would want to find and fix that 
problem rather than hacking round it, otherwise it may come and bite you 
in the bum at some later date.  Just my $0.02.


PS At one point I thought you tried and failed to find a man page for 
nsswitch.conf.  You might want to try again and check your typing as I 
can find one just fine of FreeBSD 5.4.  host.conf probably doesn't have 
one any more because it is superceded by nsswitch.conf.

More information about the freebsd-questions mailing list