New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transient hostname behaves weirdly with DHCP leases #32541
Comments
Duplicate of #17403 |
It does not seem like this is a duplicate of the referenced issue. That one is about persisting the dhcp hostname as a static hostname whereas mine is about the behavior of the hostname when dhcp does not even send one. In that case the transient hostname seems to go bonkers, gets lost/reset or whatever. |
@septatrix the transient hostname is transient, i.e. it lives only as long as the dhcp lease it is defined in is valid. We revert back to the static hostname once the dhcp lease ended. If no static hostname is defined, we fall back to the fallback hostname instead. What you are asking for is that the hostname from a DHCP least is applied not just transiently, but persistently, and that's what the "static" hostname is for. Hence to me it appears this is simply the same issue? |
No, I do not really care about the static hostname. My DHCP lease (to my knowledge) does not send even send any hostname - at least I never configured my router to do so. The "Foobar" hostname is transient and was set by me. The "Digital-Signage-Player" is not from DHCP. I actually do not know where systemd gets it from. It is the one set in the initrd (and was the hostname originally before I set it to "Foobar") but I have no clue from where systemd gets this name after I overwrote it with "Foobar". Then, after the DHCP lease expires the hostname is reset to "fedora" which is the default hostname as per os-release. I would expect it to not change the hostname (because the DHCP lease never set one) or at least revert it to "Foobar". |
this smells a lot as if it actually does come from DHCP. If you look at the sources the hostname changes the moment the dhcp lease is acquire and later lost. maybe you have a DHCP server on your wifi you are not aware of? consider setting UseHostname=no to make sure networkd doesn't use the hostname? |
Upon further inspection it seems that you are correct. The router apparently sends out hostnames - I assume to resolve hostname conflicts if several devices announce the same hostname.
Even though we do not expect to have duplicate devices on the same network we would like to preserve the ability for our customers to assign custom hostnames if they so desire. The solution we are doing now is to adjust the hostname in os-release: sed -i \
-e 's/DEFAULT_HOSTNAME="fedora"/DEFAULT_HOSTNAME="Digital-Signage-Player"/' \
"$BUILDROOT"/usr/lib/os-release Thanks for your help! |
@septatrix Editing os-release per-host is not good. Using /etc/hostname (and /etc/machine-info) is better solution. |
We are using usr/-only images and while we do have a persistent root we try to avoid putting files. We build our images using mkosi and the above hostname really is our "default hostname" for all devices so setting the field in os-release seems like a reasonable solution. |
I see. Note, if you use newer systemd, then you can use systemd.hostname= kernel command line option. (Though, I am not sure if it will be reused or not when a transient hostname is revoked.) |
systemd version the issue has been seen with
255.4-1.fc40
Used distribution
Fedora 40
Linux kernel version used
6.8.7-300.fc40.x86_64
CPU architectures issue was seen on
x86_64
Component
systemd-hostnamed, systemd-networkd, systemd-resolved
Expected behaviour you didn't see
Unexpected behaviour you saw
Steps to reproduce the problem
I am using a usr-only OS image with a default hostname set in the initrd (using mkosi's
Hostname=
option, most importantly there is no/etc/hostname
).hostnamectl --transient
.hostnamectl
(or look into the journal).hostnamectl
(or look into the journal).Additional program output to the terminal or log subsystem illustrating the issue
The text was updated successfully, but these errors were encountered: