public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Grant Taylor <gtaylor@gentoo.tnetconsulting.net>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Why do we add the local host name to the 127.0.0.1 / ::1 entry in the /etc/hosts file?
Date: Thu, 11 Mar 2021 09:50:37 -0700	[thread overview]
Message-ID: <0c71bcc1-9e55-e1d5-1b48-d3896bc09340@spamtrap.tnetconsulting.net> (raw)
In-Reply-To: <2405026.4XsnlVU6TS@lenovo.localdomain>

On 3/11/21 6:38 AM, Michael wrote:
> I'm losing my thread in this ... thread, but what I'm trying to say 
> is the AD/ DC and Kerberos way of processing the /etc/hosts entries, 
> when an /etc/hosts file is used, is different to your run of the mill 
> Linux box and server.

I disagree.

First, AD/DC ~ Kerberos don't process the /etc/hosts file.  They do ask 
the system to resolve names to IP addresses.

Second, the system will process the /etc/hosts file, DNS, NIS(+) in the 
order configured in the /etc/nsswitch file so that it can resolve names 
to IP addresses for programs that ask it to do so.

Third, both non-AD / non-Kerberos and AD / Kerberos systems ask the 
system to resolve names to IP addresses.  Further, I'll bet dollars to 
donuts that they call the same functions and use the same subsystems.

I will agree that non-AD / non-Kerberos systems are not sensitive to -- 
what some consider to be -- the misconfigurations that AD / Kerberos 
systems are.

> The Samba link in a previous message makes it clear the DC must have 
> a DNS domain, which corresponds to the domain for the AD forest, 
> this will be used by the Kerberos AD realm; and, the DC must have a 
> static IP address.

Yes.  But that has nothing to do with the contents of the /etc/hosts file.

> The syntax is:
> 
> IP_address canonical_hostname [aliases...]

Agreed.  That's what it should be.  Though I've seen all sorts of failures.

> Therefore, in an entry like:
> 
> 127.0.0.1	localhost host.example.net host
> 
> the "host.example.net" and "host" are both entered as aliases, but 
> will nevertheless resolve to 127.0.0.1 - which will break the Samba 
> AD DC requirement.

Agreed.

> The host name and FQDN must resolve to the static IP of the DC on 
> the LAN.

Remember, that this also applies to clients, not just DCs.

> Since /etc/hosts is parsed from the top, things may work fine when 
> the localhost entry is further down the list and further down than 
> any other entries acting as AD DNS resolvers - I don't recall testing 
> this on Samba to know for sure.

Why are you putting entries for the DNS servers in the /etc/hosts file?

> The same syntax won't break a LAMP, or vanilla linux PC, as long as 
> the same box is not acting as a DC.

Actually it can.  I've seen it multiple times in the past.

Bind a service to /only/ the LAN IP.  Then have the system try to 
connect to itself.  It will fail because the service isn't listening on 
the loopback IP.

This is (or was) common on web servers that had multiple IP addresses to 
use different TLS certificates before SNI became a viable thing.  Have 
each virtual web server listen on only it's specific IP address.  Have 
the virtual web server for the system's FQDN follow suit for consistency 
reasons.  Then trying to connect to the FQDN would fail if it was an 
alias for 127.0.0.1 or ::1.

> See my statement above re. entries for AD DNS resolvers, if these 
> are listed in the /etc/hosts file.

You didn't answer my question.

What does the number of DNS servers (configured in /etc/resolv.conf) 
have to do with the contents of the /etc/hosts file?

> The /etc/hosts file specifies the LAN IP address(es) of the DC which 
> acts as DNS resolver for the AD DNS zones.

No, the /etc/hosts file has nothing to do with how /DNS/ resolution 
operates.

> The DC's /etc/resolv.conf shouldn't be pointing to non-AD compatible 
> resolvers.

Which has nothing to do with the contents of /etc/hosts.

> ACK.  I hope what I've written above better reflects my understanding, 
> although it could be factually incorrect.  Other contributors should 
> soon put me right.  :-)

I'm wondering if your understanding is that there's a close relationship 
and interaction between the contents of /etc/hosts and /etc/resolv.conf 
as in the former effects the latter.  This is not the case.

/etc/hosts and /etc/resolv.conf are completely independent and can each 
quite happily exist without the other.  You can even run systems without 
one or the other.  Running without both is technically possible, but 
things start to get ... cumbersome.

You can add entries in /etc/hosts for the DNS servers as a convenience. 
But doing so has no influence on how the DNS resolution subsystem 
functions.  The DNS resolution subsystem is driven by options in the 
/etc/resolv.conf file.  And it's done independently of the contents of 
the /etc/hosts file.

Yes, the /etc/hosts file and the /etc/resolv.conf file both have to do 
with name to IP (and IP to name) resolution.  But they are as 
independent of each other as looking up a phone number in the phone book 
vs calling and asking the operator to look it up for you.  They achieve 
the same goal, but do so completely different ways and completely 
independently of each other.

This has been and is an interesting discussion.  However, I'm still no 
closer to learning why the Gentoo handbook wants the local host name 
added to the 127.0.0.1 / ::1 entry in the /etc/hosts file.  Something 
which I believe is wrong and bad advice.



-- 
Grant. . . .
unix || die


  reply	other threads:[~2021-03-11 16:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-21 22:23 [gentoo-user] Why do we add the local host name to the 127.0.0.1 / ::1 entry in the /etc/hosts file? Grant Taylor
2021-02-22  6:20 ` Andrew Udvare
2021-02-25  2:37 ` Peter Humphrey
2021-02-25  2:50   ` Grant Taylor
2021-02-25  7:02     ` Arve Barsnes
2021-02-25  7:33       ` Grant Taylor
2021-03-10  5:09 ` Grant Taylor
2021-03-10 13:27   ` Mark Knecht
2021-03-10 15:25     ` Michael
2021-03-10 16:00       ` Mark Knecht
2021-03-10 16:38         ` Michael
2021-03-10 17:07           ` Grant Taylor
2021-03-10 17:01         ` Grant Taylor
2021-03-10 16:58       ` Grant Taylor
2021-03-11 13:38         ` Michael
2021-03-11 16:50           ` Grant Taylor [this message]
2021-03-12 19:04             ` Michael
2021-03-13 19:01               ` Grant Taylor
2021-03-16 12:16                 ` Michael
2021-03-16 12:33                   ` Peter Humphrey
2021-03-16 18:54                   ` Grant Taylor
2021-03-11 17:04           ` Grant Taylor
2021-03-10 16:44     ` Grant Taylor
2021-03-10 17:43       ` Mark Knecht
2021-03-10 18:37         ` Grant Taylor
2021-03-11 10:54           ` Wols Lists

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c71bcc1-9e55-e1d5-1b48-d3896bc09340@spamtrap.tnetconsulting.net \
    --to=gtaylor@gentoo.tnetconsulting.net \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox