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

Re: hostname is being reset, killing net on reboot



On Sun 23 Jan 2022 at 15:01:09 (-0500), Greg Wooledge wrote:
> On Sun, Jan 23, 2022 at 07:09:27PM +0000, Brian wrote:
> > On Sun 23 Jan 2022 at 13:53:01 -0500, gene heskett wrote:
> > > On Sunday, January 23, 2022 1:26:56 PM EST Felix Miata wrote:
> > > > Greg Wooledge composed on 2022-01-23 08:42 (UTC-0500):
> > > > > On Sun, Jan 23, 2022 at 08:50:56AM +0100, Andrei POPESCU wrote:
> > > > >> As far as I can tell (with my limited understanding of DNS) it only
> > > > >> makes it easier to share /etc/hosts with no obvious downside.
> > > > > 
> > > > > If that actually works, that's great news for Gene.  It means he can
> > > > > duplicate a single /etc/hosts file across all systems without needing
> > > > > to bolt on a unique per-system header afterward.
> > > > 
> > > > I've been sharing the very same hosts file among all my PCs for well
> > > > over a decade, probably closer to two.
> > > 
> > > And I have been for 2 decades and change as it once had an amiga as one 
> > > of its clients.
> > 
> > What advice would you give to a user regarding the benefits of a hosts
> > file as opposed to more modern techniques?
> 
> I'll treat this question as "static interface configuration and hosts
> files".
> 
> The advantage is that it's conceptually simpler.
> 
> The disadvantages are numerous.
> 
>  * Adding a new host, or changing a host's IP address, requires
>    platform-specific knowledge on the host in question.  On a
>    heterogeneous network, that means you need knowledge of how to do
>    this on all the different platforms.  This may include devices like
>    printers, where it's quite difficult, maybe even impossible, to
>    configure an address without DHCP.
> 
>  * After a change is made, it has to be replicated across your entire
>    network.  Manually.
> 
>  * Any "visitor" machines that are temporarily added to your network will
>    need to be configured manually, and they will have zero knowledge of
>    the other hosts on the network.  Even if you know their names, there
>    won't be any DNS in which you can look up their addresses.
> 
> For anyone setting up a new home network, I'd recommend using DHCP.  It
> will be a lot simpler in the long run, especially if you start adding
> wireless devices (cell phones, tablets, TV streaming devices, etc.).
> Your router probably already acts as a DHCP server, so all you need to
> do is learn how to configure fixed addresses for specific computers (and
> printers) that want to act like servers.  The other devices can just get
> random addresses.  Guest machines can just be connected and start working
> without issues.

Yes, I'd agree with all those arguments for DHCP, which is why I use
it, hence its inclusion in my post at the top of this subthread, and
why I can't understand Gene's aversion to it. But that's all about
configuration, and the quoted comment at the top of this post is AIUI
about /resolving/ hostnames through /etc/hosts.

Some of us (not including Gene) don't have DNS resolvers built into
our routers, and don't want to have to run 24/7 yet another piece of
hardware (other than the already necessary modem and router
(routers in my case).

So from the list of IP addresses, hostnames and MAC addresses,
configured into and printed out from my master router, I compiled
a master list of the first and second items, which is transformed
into /etc/hosts as already shown. From the length of my list,
I'd estimate an addition or deletion occurs about twice a year—
less frequently really, as often they're paired +-.

(And I did answer Andrei's comment, albeit after you'd posted.
It's no harder to distribute transformed files than identical ones.)

But to get back to Gene's network, and his lack of certainty that,
when "ssh -Y rpi4" is typed, "dhcp hasn't rerouted my ssh session
to tlm.coyote.den." Well, from what we've been told (or it might be
from what's been gleaned over the years), we have a dozen machines
with, we hope, identical lists of hostname≡IPaddress in /etc/hosts,
but instead of a single location for their IPaddress configuration,
we have a dozen /e/n/i files. Just to make it more difficult to check
them, none of the latter will contain a hostname, of course, but only
a static IP address.

That seems a lot less robust than having two lists that can be
compared side by side, as I described in my own setup. If I had
a setup like that, I'd make sure that my /etc/hosts-distribution
script provoked a script on the target to check that the address
in /e/n/i matched the target's entry in /etc/hosts.

A couple of posts further up this subthread:

> > > > >> On Sb, 22 ian 22, 20:07:45, David Wright wrote:
> > > > >> > On Sat 22 Jan 2022 at 13:57:38 (-0500), gene heskett wrote:
> > > > >> > > Linux goes out of its way to kill networking by ignoring what I put in a 
> > > > >> > > file in /etc/network/interfaces.d/anyoldname. And when some coder dinking 
> > > > >> > > around in dhcp code thinks the whole world is volatile, and changes a 
> > > > >> > > hostname just because they can boggles my mind. But its the only way to 
> > > > >> > > have a sane local network with STABLE names and addresses.
> > > > >> > No idea what you're talking about here.

It later struck me that there's a clue in Gene writing: "Linux [ignores]
what I put in a file in /etc/network/interfaces.d/anyoldname."

I can only assume that that means Gene has observed a disagreement between:

  /etc/hosts on any host containing

       IPADDR  HOSTNAME

and:

  /etc/network/interfaces.d/anyoldname on the host HOSTNAME containing

       address IPADDR/24

Unless, of course, Gene has "nuked" /e/n/i (strictly, the file
/etc/network/interfaces itself).

Cheers,
David.


Reply to: