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

Re: where is /etc/hosts supposed to come from?

On Tue, Dec 29, 2009 at 02:52:44PM +0100, Vincent Lefevre wrote:

> When the machine is correctly configured (i.e. really has a FQDN),
> "hostname -f" is reliable.

No, it is not. "hostname -f" can return one value only, while a host may
have dozens or hundreds of valid FQDNs.

Example: there is a router box called "gw" which has about a dozen
addresses that resolve to "gw.<domain>" for just as many domains. Some
addresses even share the same NIC. Which FQDN should "hostname -f"
display? Why that one, and not some other?

I've submitted a patch for hostname (#562830) to add two new options:
one that displays all IP addresses of the host, while the other displays
all the FQDNs for those addresses. Neither relies on the value returned
by gethostname(), so "the hostname must be an FQDN" misbelief together
with any usage of "hostname -f" can die a silent death.


     MTA SZTAKI Computer and Automation Research Institute
                Hungarian Academy of Sciences

Reply to: