Skip to content

CA-412636: hostname changed to localhost with static IP and reboot #6546

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

liulinC
Copy link
Collaborator

@liulinC liulinC commented Jun 20, 2025

According to
https://www.freedesktop.org/software/systemd/man/latest/hostname.html Systemd set hostname with following sequence

  • kernel parameter, systemd.hostname
  • static hostname in /etc/hostname
  • transient hostname like DHCP
  • localhost at systemd compile time

Once the host is configured with static IP and reboot, it would just lost its hostname as no DHCP or static IP available.

However, the hostname is critical to AD function as it construct the machine account.

The hostname should be persisted as static name during joining AD, this is also what PBIS does.

Note: the static hostname is not cleaned during domain leave. This is by intention to avoid losing hostname after reboot with static IP

0307adc6 tried to resovle the issue and update /etc/resolv.conf However, /etc/resolv.conf does not help and conflict with xcp-networkd, as networkd override the configure every 5 minutes Here we just revert the resolv.conf update

@edwintorok
Copy link
Contributor

I can't find commit 0307adc6, do you have the full git hash and title?

According to
https://www.freedesktop.org/software/systemd/man/latest/hostname.html
Systemd set hostname with following sequence
- kernel parameter, systemd.hostname
- static hostname in /etc/hostname
- transient hostname like DHCP
- localhost at systemd compile time

Once the host is configured with static IP and reboot, it would
just lost its hostname as no DHCP or static IP available.

However, the hostname is critical to AD function as it construct the
machine account.

The hostname should be persisted as static name during joining AD,
this is also what PBIS does.

Note: the static hostname is not cleaned during domain leave.
This is by intention to avoid losing hostname after reboot with static IP

cba2f1d tried to resovle the issue and update /etc/resolv.conf
However, /etc/resolv.conf does not help and conflict with
xcp-networkd, as networkd override the configure every 5 minutes
Here we just revert the resolv.conf update. Other parts of that commit
can still benifit as it push the hostname to DNS

Signed-off-by: Lin Liu <Lin.Liu01@cloud.com>
@liulinC liulinC force-pushed the private/linl/xsi-1918-pr branch from 5b54001 to ce45a11 Compare June 20, 2025 10:24
@liulinC
Copy link
Collaborator Author

liulinC commented Jun 20, 2025

I can't find commit 0307adc6, do you have the full git hash and title?

Sorry, I got the commit ID from wrong branch (my dev branch before merged to master), thus wrong commit id.
it should be cba2f1d, and updated the commit message.

@lindig
Copy link
Contributor

lindig commented Jun 20, 2025

So the approach of rewriting resolve.conf was wrong? But this was done for a purpose - it that still achieved?

@liulinC
Copy link
Collaborator Author

liulinC commented Jun 21, 2025

So the approach of rewriting resolve.conf was wrong? But this was done for a purpose - it that still achieved?

writing resolve.conf is NOT wrong, on the contrary, it is right
It absolutely make sense to write domain into resolv.conf . (there is a customer do expect that and there is an XSI for that).

However, simply write to that file conflict with networkd, I may update later to call networkd to update the domain later, (update_config). but that will require more test.

This PR overriding the hostname just follows what PBIS does, and it resolve the localhost issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants