[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: /etc/hosts: Two lines with the same IP address?



* Thomas Hood

 > The question has arisen in #247734:
 >
 > Is it legal for /etc/hosts to contain two lines with the same
 > IP address?  In particular, is the following legal?:
 >
 >     127.0.0.1	localhost
 >     127.0.0.1	pingo
 >
 > What is nice about it is this:
 >
 >     $ hostname
 >     pingo
 >     $ hostname --fqdn
 >     pingo
 >
 > One can of course have:
 >
 >     127.0.0.1	localhost	pingo
 >
 > but then:
 >
 >     $ hostname --fqdn
 >     localhost

  Set 'pingo' as the first in the list.  hostname --fqdn merely does
 a gethostbyname() on what's given by gethostname().  The first in the
 list is the h_name member of the returned hostent struct, and is what
 hostname --fqdn assumes to be the fully qualified hostname.  The
 remaining entries is assumed to be aliases only.

  But the first entry should rather have been 'pingo.domain.com'
 with 'pingo' as the alias.

  On a related note, I've never quite understood why the installer
 insists that the domain name must not be part of the hostname.  Quite
 annoying, really.  Is that fixed in d-i?

-- 
Tore Anderson



Reply to: