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

Re: hostname?



ghe wrote: 
> On 10/4/19 1:36 PM, Dan Ritter wrote:
> 
> root@pix:~# cat /etc/hostname
> sbox

This is good.

> > /etc/hosts
> 
> root@pix:~# cat /etc/hosts

...

> 127.0.0.1	localhost.localdomain		localhost lh lcl

this is fine. Some mechanisms like to pick up a non-localhost
name in 127/8 and pretend it's the hostname.


> > the output of
> > 
> > hostname -f
> 
> root@pix:~# hostname -f
> hostname: Name or service not known

OK

> > hostnamectl
> 
> root@pix:~# hostnamectl
>    Static hostname: sbox
> Transient hostname: pix
>          Icon name: computer-desktop
>            Chassis: desktop
>         Machine ID: d01c1f97efc944bd81768d849446feaf
>            Boot ID: 50e006fce53c47a881b78f09c0bbcbe2
>   Operating System: Debian GNU/Linux 10 (buster)
>             Kernel: Linux 4.19.0-6-amd64
>       Architecture: x86-64
> 
> 
> Hmm. That's interesting. Transient hostname. I didn't know of
> hostnamectl. Tells what it is, but not what to do about it or where it
> came from.

Righto. systemd strikes again. Here's the relevant man page
bits:

hostnamectl may be used to query and change the system hostname
and related settings.

This tool distinguishes three different hostnames: the
high-level "pretty" hostname which might include all kinds of
special characters (e.g. "Lennart's Laptop"), the static
hostname which is used to initialize the kernel hostname at boot
(e.g. "lennarts-laptop"), and the transient hostname which is a
fallback value received from network configuration. If a static
hostname is set, and is valid (something other than localhost),
then the transient hostname is not used.

----


In this case, systemd has helpfully decided that a name it is
picking up from DHCP (most likely) is your system's temporary
name. I'm not sure why anyone thought this was a good idea, but
that's what it is.

You can probably tell your dhcp client not to ask for the
temporary/transient hostname, or tell systemd not to do this
thing, but I don't know precisely how.

-dsr-


Reply to: