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

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



On 2009-12-30 11:56:13 +0100, Gabor Gombas wrote:
> On Tue, Dec 29, 2009 at 10:31:25PM +0100, Vincent Lefevre wrote:
> > Then you need to configure your machine according to the spec, i.e.
> > you need a single FQDN / canonical name / official name of the host.
> 
> If getaddrinfo(AI_CANONNAME) fails, that is fully conformant with the
> spec you have quoted.

But that's a ***FAILURE***. Don't assume that things will work
perfectly in such a case.

> > > 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?
> > 
> > This doesn't really matter. The FQDN may also be another name, i.e.
> > the nodename may be something more meaningful than "gw".
> 
> But it is not. This is a real world example. Reality does not match
> your dream world.

Could you please read again what I've written? I've said *may*.
"gw" is fine too, if you really want. No theoratical problem with
that.

> > You should ask this question to those who configured such routers
> > (but this would be more a practical matter, as you may have plenty
> > of choices).
> 
> _I_ did configure it. I _know_ that none of the addresses is more
> important than the other.

So what?

> And you know, if you do not pretend such silly things that a host should
> have just a single FQDN or that "hostname -f" should return anything
> meaningful, then the above configuration works flawlessly. Only if you
> start to pretend things that are simply not true you start having
> problems.

I'm not pretending, this is how it is. RTFM.

> > A FQDN is not associated with an IP address, but with a host. You
> > cannot call them FQDN, which already has a well-established meaning.
> 
> Now this is bullshit. FQDN is a term related to DNS.

Wrong. /etc/hosts (which is commonly used for the FQDN) has nothing to
do with DNS.

> An FQDN resolves to a set of resource records, which may be IPv4 or
> IPv6 addresses and a couple of other things, but definitely _NOT_
> hosts, as that term has no meaning for the DNS.

I've never said that a FQDN resolves to hosts.

> If the FQDN resolves to multiple IP addresses, then the very same FQDN
> can belong to multiple hosts simultaneously.

I'd say that's an incorrect configuration. Several mechanisms may fail
in such a case (e.g. Message-Id generation).

> Similarly, if a host has multiple IP addresses, then multiple FQDNs
> may point to it. You can even mix these:
> 
> - host1 has addresses 192.168.1.1 and 192.168.2.1
> - host2 has addresses 192.168.1.2 and 192.168.2.2
> - the DNS has the following records:
> 
> 	service1.domain.	IN	A	192.168.1.1
> 				IN	A	192.168.1.2
> 	service2.domain.	IN	A	192.168.2.1
> 				IN	A	192.168.2.2

One often uses CNAME for services, or the FQDN may be a bit more
hidden. For instance:

$ host www.google.com
www.google.com is an alias for www.l.google.com.
www.l.google.com has address 209.85.227.106
www.l.google.com has address 209.85.227.147
www.l.google.com has address 209.85.227.99
www.l.google.com has address 209.85.227.103
www.l.google.com has address 209.85.227.104
www.l.google.com has address 209.85.227.105
$ host 209.85.227.106
106.227.85.209.in-addr.arpa domain name pointer wy-in-f106.1e100.net.
$ host 209.85.227.147
147.227.85.209.in-addr.arpa domain name pointer wy-in-f147.1e100.net.

and so on. (I'm not saying that wy-in-f106.1e100.net,
wy-in-f147.1e100.net and so on are the FQDN's of these hosts,
but this is probably the case.)

In your example, host1.domain and host2.domain could be the respective
FQDN's of these hosts, that could resolve as 127.0.1.1 locally on each
machine.

> > If I understand correctly, you do a reverse DNS lookup. Now, I'm
> > wondering... Can a hostname obtained by reverse DNS lookup resolve
> > to different IP addresses?
> 
> Of course it can.

So, this would mean that your new option --all-fqdns would lie,
as it could give IP's belonging to other machines.

> > "hostname -f" just follows the POSIX notion of canonical name (a.k.a.
> > FQDN). So, I doubt it will die.
> 
> Please quote the exact text from POSIX that says that
> 
> - there MUST be a canonical name,
> - and that name MUST be an FQDN.

For instance, under getnameinfo():

  The flags argument is a flag that changes the default actions of the
  function. By default the fully-qualified domain name (FQDN) for the
  host shall be returned, but:

This means that a host *has* a FQDN (POSIX doesn't say "if there is
one" and something like that). It is just an implementation-defined
property of the system.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


Reply to: