Why is hostname and $HOSTNAME different?
Bo Berglund
bo.berglund at gmail.com
Wed May 11 19:08:22 UTC 2022
On Wed, 11 May 2022 10:06:55 -0700, Tom Mitchell <niftyubuntu at niftyegg.com>
wrote:
>The easy answer first: Yes DHCP can set the hostname. If that is how
>you set it.
>
>Next search to see how you set the hostnames (yes plural) for your machine.
>Start with /etc/hostname
>Next /etc/hosts
>Then DNS
>Note that hostname is per network interface and that includes
>localhost 127.0.0.1
>I have different names and IP addresses for local loopback, wired
>ethernet and WiFi.
>
>These are close enough to be a simple typo
> ubuntusrv
> ubuntuserv
>
I found this command on the net:
$ hostnamectl
Static hostname: ubuntuserv
Transient hostname: ubuntusrv
Icon name: computer-desktop
Chassis: desktop
Machine ID: f604e0e6137f58f8d2b3ebfc5a6fb461
Boot ID: db4430ae2f5847a29693c05e26a8e63e
Operating System: Ubuntu 20.04.4 LTS
Kernel: Linux 5.4.0-89-generic
Architecture: x86-64
Notice the "transient hostname"!
What is that?
How can I get rid of the transient name?
Well, I have now changed the DHCP entry in the router so it may get resolved
next time it refreshes the lease.
--
Bo Berglund
Developer in Sweden
More information about the ubuntu-users
mailing list