On Sun 08 May 2022 at 19:20:05 (-0600), Charles Curley wrote: > On Sun, 8 May 2022 19:42:57 -0500 David Wright wrote: > > > I'm really not sure who, and under what circumstances, > > hostnamectl is for. > > Nor am I, especially after this. According to apt-file, it is in the > package systemd. > > > I ran: > > > > # hostnamectl set-hostname acerx > > > > and /etc/hostname was changed, but not /etc/hosts, which still had: > > > > 127.0.1.1 acer.corp acer > > I confirm this. I guess I missed it due to rarely referring to a > computer by its hostname, but instead by localhost. Sigh. Thanks for > the catch. It looks like I shall have to adjust my installation scripts. > > > > > and also not /etc/mailname. I'm not saying it should have affected > > those occurrences, but that it's better to check you have the > > correct, consistent name throughout the system. > > Odd. On the two boxes I used hostnamectl on, mailname is set correctly. > However, I ran it on installation, and may have fixed that manually > (but there's no backup file), or by installing postfix subsequently.
Well, I was running hostnamectl after the event, ie on an already fully-configured system. In your case, you probably configured exim after setting the hostname (or it's the same name anyway, or whatever). OTOH I think dpkg-reconfigure reads the mailname from /etc/hosts, rather than /etc/hostname, initially (ie when /etc/mailname is unset. If it's already set, it just parrots it.). > > It's also not clear to me either, where one might insert this command > > so that it takes effect early enough to avoid polluting the system > > with wrong names. (The logs, for one example.) > > I run it in a script that I run manually immediately after installation. I see. And it sets /etc/hostname for good. But I think the OP's problem might have been that DHCP was overwriting /etc/hostname each time it ran (or ran at boot time). > > > > Whats I didn't check was what my router took to be my host name. > > > > It did not reponse to my changed host name and I had to do it > > > > manually in the router. Doing do seems to have solved my problem. > > > > > > > > It would seem then that you were letting DHCP in the router set your > > hostname as well as the usual IP address, nameservers etc, which > > could be unfortunate if it doesn't agree. How you avoid that depends > > …. > > Yup. However I make sure they agree by assigning most hosts a "host" > statement in dhcpd.conf, and assigning a fixed IP address to a given MAC > address, and then having dhcpd feed that to bind9. Similarly here, except that I don't have anything running a DNS server. But the router's DHCP table's hostname agrees with /etc/hostname, /etc/hosts, /etc/mailname, and any derived places like update-exim4.conf.conf and the ssh keys. BTW my "…" stood for "different with different configurations", and I don't think I can even avoid it on my own preferred DHCP client, iwd. (I think I have seen a post proferring a patch to allow it.) Cheers, David.