Coder Social home page Coder Social logo

Comments (9)

poettering avatar poettering commented on June 21, 2024

Duplicate of #17403

from systemd.

septatrix avatar septatrix commented on June 21, 2024

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.

from systemd.

poettering avatar poettering commented on June 21, 2024

@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?

from systemd.

septatrix avatar septatrix commented on June 21, 2024

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".

from systemd.

poettering avatar poettering commented on June 21, 2024

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.

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?

from systemd.

septatrix avatar septatrix commented on June 21, 2024

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.

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?

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.

consider setting UseHostname=no to make sure networkd doesn't use the 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!

from systemd.

yuwata avatar yuwata commented on June 21, 2024

@septatrix Editing os-release per-host is not good. Using /etc/hostname (and /etc/machine-info) is better solution.

from systemd.

septatrix avatar septatrix commented on June 21, 2024

@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 also opened an issue in mkosi to do this when Hostname= is present in the mkosi configuration

from systemd.

yuwata avatar yuwata commented on June 21, 2024

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.)

from systemd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.