1 |
On Thursday, 11 March 2021 16:50:37 GMT Grant Taylor wrote: |
2 |
> On 3/11/21 6:38 AM, Michael wrote: |
3 |
> > I'm losing my thread in this ... thread, but what I'm trying to say |
4 |
> > is the AD/ DC and Kerberos way of processing the /etc/hosts entries, |
5 |
> > when an /etc/hosts file is used, is different to your run of the mill |
6 |
> > Linux box and server. |
7 |
> |
8 |
> I disagree. |
9 |
> |
10 |
> First, AD/DC ~ Kerberos don't process the /etc/hosts file. They do ask |
11 |
> the system to resolve names to IP addresses. |
12 |
|
13 |
Yes, of course. I realise I didn't express this point accurately. I think |
14 |
the hosts file is parsed, if it exists, by the glibc which then provides the |
15 |
required IP info to applications. |
16 |
|
17 |
|
18 |
> Second, the system will process the /etc/hosts file, DNS, NIS(+) in the |
19 |
> order configured in the /etc/nsswitch file so that it can resolve names |
20 |
> to IP addresses for programs that ask it to do so. |
21 |
|
22 |
Yes, /etc/hosts could be even be configured to be the last source to be |
23 |
consulted, or not exist at all. |
24 |
|
25 |
|
26 |
> Third, both non-AD / non-Kerberos and AD / Kerberos systems ask the |
27 |
> system to resolve names to IP addresses. Further, I'll bet dollars to |
28 |
> donuts that they call the same functions and use the same subsystems. |
29 |
> |
30 |
> I will agree that non-AD / non-Kerberos systems are not sensitive to -- |
31 |
> what some consider to be -- the misconfigurations that AD / Kerberos |
32 |
> systems are. |
33 |
|
34 |
Right. That's the nub of it. Samba, with AD-DC and Kerberos configuration |
35 |
deserves special attention and the apps devs advise accordingly. |
36 |
|
37 |
|
38 |
> > The Samba link in a previous message makes it clear the DC must have |
39 |
> > a DNS domain, which corresponds to the domain for the AD forest, |
40 |
> > this will be used by the Kerberos AD realm; and, the DC must have a |
41 |
> > static IP address. |
42 |
> |
43 |
> Yes. But that has nothing to do with the contents of the /etc/hosts file. |
44 |
|
45 |
It does, insofar the hosts file contents and syntax could break Samba, AD/DC |
46 |
and Kerberos, if the Samba devs advice is not heeded. |
47 |
|
48 |
Unless I got all this thread wrong, this is the main bone of contention - |
49 |
handbook recommendations can lead to such breakage. |
50 |
|
51 |
|
52 |
[snip...] |
53 |
|
54 |
> > Since /etc/hosts is parsed from the top, things may work fine when |
55 |
> > the localhost entry is further down the list and further down than |
56 |
> > any other entries acting as AD DNS resolvers - I don't recall testing |
57 |
> > this on Samba to know for sure. |
58 |
> |
59 |
> Why are you putting entries for the DNS servers in the /etc/hosts file? |
60 |
|
61 |
You wouldn't normally add in the hosts file the IP addresses of DNS |
62 |
forwarders/resolvers, but depending on the topology of the AD forest you could |
63 |
if you wanted to. |
64 |
|
65 |
|
66 |
> > The same syntax won't break a LAMP, or vanilla linux PC, as long as |
67 |
> > the same box is not acting as a DC. |
68 |
> |
69 |
> Actually it can. I've seen it multiple times in the past. |
70 |
> |
71 |
> Bind a service to /only/ the LAN IP. Then have the system try to |
72 |
> connect to itself. It will fail because the service isn't listening on |
73 |
> the loopback IP. |
74 |
|
75 |
Quite. If you set up this service to only listen to the LAN IP address, |
76 |
rather than any address, it should do just so. There is also the question why |
77 |
should a service for the LAN need to listen to localhost, it's not always |
78 |
necessary. |
79 |
|
80 |
|
81 |
> This is (or was) common on web servers that had multiple IP addresses to |
82 |
> use different TLS certificates before SNI became a viable thing. Have |
83 |
> each virtual web server listen on only it's specific IP address. Have |
84 |
> the virtual web server for the system's FQDN follow suit for consistency |
85 |
> reasons. Then trying to connect to the FQDN would fail if it was an |
86 |
> alias for 127.0.0.1 or ::1. |
87 |
|
88 |
Yes, I recall apache would fail if you tried to contact http://localhost or |
89 |
its FQDN from the server itself, with something like "... host name not valid |
90 |
for this server", but it would serve the default "It works!" webpage when the |
91 |
server's FQDN was called from clients. Anyway, all this is O/T from the main |
92 |
question. |
93 |
|
94 |
|
95 |
> > See my statement above re. entries for AD DNS resolvers, if these |
96 |
> > are listed in the /etc/hosts file. |
97 |
> |
98 |
> You didn't answer my question. |
99 |
> |
100 |
> What does the number of DNS servers (configured in /etc/resolv.conf) |
101 |
> have to do with the contents of the /etc/hosts file? |
102 |
|
103 |
It doesn't, obviously the two files are fulfilling different purposes. You |
104 |
could however specify in the DC's host file any additional DNS servers in the |
105 |
AD DNS zone with their static IP addresses. I tend to do this and also check |
106 |
the hosts file in the first instance when I forget what other machines play |
107 |
some (important) role on the current host's functions. This is by no means a |
108 |
rule or even a recommendation for others to do the same. ;-) |
109 |
|
110 |
|
111 |
> > The /etc/hosts file specifies the LAN IP address(es) of the DC which |
112 |
> > acts as DNS resolver for the AD DNS zones. |
113 |
> |
114 |
> No, the /etc/hosts file has nothing to do with how /DNS/ resolution |
115 |
> operates. |
116 |
|
117 |
Yes, but I was not referring to DNS resolution mechanism itself, other than |
118 |
specifying static addresses of other DCs PCs in the hosts file. It's just a |
119 |
list of IP addresses after all. Since the localhost (DC) provides DNS |
120 |
resolution, its LAN address will be included. |
121 |
|
122 |
|
123 |
> I'm wondering if your understanding is that there's a close relationship |
124 |
> and interaction between the contents of /etc/hosts and /etc/resolv.conf |
125 |
> as in the former effects the latter. This is not the case. |
126 |
|
127 |
Yes, we agree. Two different files, mechanisms and purposes. |
128 |
|
129 |
|
130 |
> /etc/hosts and /etc/resolv.conf are completely independent and can each |
131 |
> quite happily exist without the other. You can even run systems without |
132 |
> one or the other. Running without both is technically possible, but |
133 |
> things start to get ... cumbersome. |
134 |
> |
135 |
> You can add entries in /etc/hosts for the DNS servers as a convenience. |
136 |
|
137 |
Yes, that's what I was trying to express, evidently unsuccessfully. :-) |
138 |
|
139 |
|
140 |
[snip... ] |
141 |
|
142 |
> This has been and is an interesting discussion. However, I'm still no |
143 |
> closer to learning why the Gentoo handbook wants the local host name |
144 |
> added to the 127.0.0.1 / ::1 entry in the /etc/hosts file. Something |
145 |
> which I believe is wrong and bad advice. |
146 |
|
147 |
I wouldn't call it majorly "wrong" on a standalone desktop use case, in the |
148 |
sense that it shouldn't break things - I think. Address 127.0.0.1 is for |
149 |
internal consumption, it won't be seen by the external network and the host |
150 |
can refer to itself as its user desires. Furthermore, LAN addresses and |
151 |
domains may change all the time on say a roaming laptop, so setting up aliases |
152 |
against a temporary LAN IP becomes cumbersome. Yes, specifying a FQDN against |
153 |
localhost doesn't align with the practice of most distros and a number of |
154 |
RFCs, therefore asking why the handbook offers this guidance without |
155 |
qualifying it is worth exploring further. |
156 |
|
157 |
We have already established the handbook suggestion creates breakage on Samba |
158 |
with AD/DC, potentially on a webserver, and perhaps other server applications. |
159 |
I agree using 127.0.0.1 for the special "localhost" hostname is cleaner and in |
160 |
these use cases the right solution. |
161 |
|
162 |
I recalled old bugs filed about this and had a look. I don't know of other |
163 |
dev conversations/bugs and what might have produced the current guidance in |
164 |
the handbook: |
165 |
|
166 |
https://bugs.gentoo.org/40203 |
167 |
https://bugs.gentoo.org/53188 |
168 |
|
169 |
|
170 |
Interestingly you attracted my attention to the man page for the hosts file, |
171 |
which I assume is installed by baselayout. I noticed this example quoted at |
172 |
the bottom where 127.0.1.1 is used for the host's FQDN: |
173 |
|
174 |
EXAMPLES |
175 |
# The following lines are desirable for IPv4 capable hosts |
176 |
127.0.0.1 localhost |
177 |
|
178 |
# 127.0.1.1 is often used for the FQDN of the machine |
179 |
127.0.1.1 thishost.mydomain.org thishost |
180 |
192.168.1.10 foo.mydomain.org foo |
181 |
192.168.1.13 bar.mydomain.org bar |
182 |
146.82.138.7 master.debian.org master |
183 |
209.237.226.90 www.opensource.org |
184 |
|
185 |
# The following lines are desirable for IPv6 capable hosts |
186 |
::1 localhost ip6-localhost ip6-loopback |
187 |
ff02::1 ip6-allnodes |
188 |
ff02::2 ip6-allrouters |
189 |
|
190 |
|
191 |
If the Gentoo handbook recommends something different, I think the devs should |
192 |
at least qualify why this is so and potentially offer warnings on use cases |
193 |
where the handbook recommendation is inappropriate and must be deviated from. |