On Tue, Feb 23, 2021 at 08:21:48PM -0500, Gene Heskett wrote:
> On Tuesday 23 February 2021 19:22:19 James B wrote:
>
> > With systemd-based Debian, the probably now best way to set a hostname
> > is with:
> >
> > hostnamectl set-hostname NAME
> >
> > What Tom suggested is completely valid, but hostnamectl should I
> > understand be the preferred route [...]
...if you restrict yourself to the systemd world [0], that is.
> Does this also have a set-domainname option? This also is disappearing on
> a reboot. Not ack the man page so I assume there is a different method
> to handle that?
Gene, please read the hostname(1) man page. It is short and sweet
(120 - 240 lines, depending on your screen width). It's all in there.
Choice quotes:
- from the top
NAME
hostname - show or set the system's host name
domainname - show or set the system's NIS/YP domain name
ypdomainname - show or set the system's NIS/YP domain name
nisdomainname - show or set the system's NIS/YP domain name
dnsdomainname - show the system's DNS domain name
you can safely ignore all that NIS/YP [1] part, that rules out the
variants 2-4; the last variant only shows the DNS domain name --
you'd have to talk to Someone Else (TM) to change that. This leaves
variant (1), i.e. hostname.
Now:
DESCRIPTION
[...]
SET NAME
When called with one argument or with the --file option, the
commands set the host name or the NIS/YP domain name [...]
So... it seems we're out of luck? Only changing your domain if it is
with NIS/YP is supported? But, oh, lookee...
THE FQDN
The FQDN (Fully Qualified Domain Name) of the system is the
name that the resolver(3) returns for the host name, such as,
ursula.example.com [...]
You cannot change the FQDN with hostname or dnsdomainname.
The recommended method of setting the FQDN is to make the
hostname be an alias for the fully qualified name using
/etc/hosts, DNS, or NIS [...]
So if your domain isn't imposed on your host by DNS (you would
know that, since that's your home network, and you'd have done
some setup to enforce that or by NIS/YP (you most probably don't
have that, your network admin, i.e. you, would know that), the
result is... go look in your /etc/hosts [2] for the domain name
your box thinks it has.
This seemingly baroque thing is due that the domain name "in"
which your box lives is a decision that not always can be
taken by your box alone. Like when I'm in France, I can't say
"I'm in Luxembourg" unless I am a rich person ;-)
(Exchange perhaps France for U.S. and Luxembourg for Delaware
for those west of the pond. For those elsewhere, please teach
me: where are your favourite tax paradises?)
Cheers
[0] Me? I prefer to stay portable. Works consistently across
systemd and non-systemd boxes.
[1] https://en.wikipedia.org/wiki/Network_Information_Service
[2] which kinda makes sense: if you squint a bit, /etc/hosts
is sorta the "poor person's DNS". Read on the resolver, and
/etc/resolv.conf for the next rabbit hole.
- t
Attachment:
signature.asc
Description: Digital signature