Hide Forgot
Description of problem: "hostname -f" report no address associated after change hostname from cockpit. It leads host to ping itself failed. Version-Release number of selected component (if applicable): ovirt-node-ng-installer-ovirt-3.6-2016042323.iso cockpit-0.103-1.el7.centos.x86_64 cockpit-ovirt-0.5.1-0.0.master.el7.centos.noarch How reproducible: 100% Steps to Reproduce: 1. Anaconda install NGN 4.0. 2. Start cockpit service. 3. Change hostname to "test.redhat.com" in cockpit. 4. Check in terminal. # hostname -f 5. Ping itself. # ping test.redhat.com Actual results: 1. After step4, the output is as follows. # hostname -f hostname: No address associated with hostname 2. After step5, the output is as follows. # ping test.redhat.com ping: unknown host test.redhat.com Expected results: 1. Hostname can be accessed to itself after configuration. Additional info:
Can you please try to reproduce this on RHEL. Please use hostnamectl set-hostname <hostname> to change the hostname. This could be a systemd-hostnamed bug.
(In reply to Fabian Deutsch from comment #1) > Can you please try to reproduce this on RHEL. > > Please use hostnamectl set-hostname <hostname> to change the hostname. > > This could be a systemd-hostnamed bug. Hi fabian, For this issue, i did not change the hostname from node side. The hostname changes are setup by cockpit. Do I need to change the hostname in node side? Thanks, Hui Wang
Yes, I understand, but I try to find the component which is causing this. Can you please try instead of using Cockpit to change the hostname, use hostnamectl set-hostname <name> on Node. If it reproduces with this, then please also try on RHEL:
(In reply to Fabian Deutsch from comment #3) > Yes, I understand, but I try to find the component which is causing this. > > Can you please try instead of using Cockpit to change the hostname, use > hostnamectl set-hostname <name> on Node. If it reproduces with this, then > please also try on RHEL: Test in rhev-hypervisor7-ng-3.6-20160429.0: # hostnamectl set-hostname retest1.redhat.com # hostname -f hostname: Name or service not known # ping retest1.redhat.com ping: unknown host retest1.redhat.com Test in RHEL-7.2-GA version: # hostnamectl set-hostname retest.redhat.com # hostname -f hostname: Name or service not known # ping retest.redhat.com ping: unknown host retest.redhat.com It's the same in RHEL-7.2-GA and node-4.0.
Lukas, is this the expected behavior of hostnamectl?
hostnamctl only change the hostname(s), which in your case should only be retest1, I am not sure where hostname -f takes the domain part.
$ man hostname hostname will print the name of the system as returned by the gethostname(2) function. hostname -f will rint the hostname including the fqdn. I assume that the FQDN part as mentioned in comment 0 can not be set with definetly hostname and probably also not makes sense to be set with hostnamectl. At the bottom my take is that: `hostnamectl` should also set the hostname in such a way that `hostname` will return this hostname. Because of this I am moving this bug to systemd. However, neither `hostname` nor `hostnamectl` should not be used to set an FQDN, because the FQDN is composed of the hostname and domain parts, and the domain part is outside of the control of a host.
hostname -f returns the result based on the answer from nss. Nothing systemd related, sorry.
Hui, could you please provide /etc/nsswitch.conf? On my Fedora 22 it all seems to work correctly: [fabiand@tee ~]$ sudo hostnamectl set-hostname tee.local3 [fabiand@tee ~]$ cat /etc/hostname tee.local3 [fabiand@tee ~]$ hostname tee.local3 ^^ Correct [fabiand@tee ~]$ sudo hostnamectl set-hostname tee.local [fabiand@tee ~]$ cat /etc/hostname tee.local [fabiand@tee ~]$ hostname tee.local ^^ Correct [fabiand@tee ~]$ grep hosts /etc/nsswitch.conf #hosts: db files nisplus nis dns hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname mymachines Let#s see if you nsswitch.conf is different.
For example [root@notas ~]# cat /etc/os-release | head -2 NAME=Fedora VERSION="22 (Twenty Two)" [root@notas ~]# grep ^host /etc/nsswitch.conf hosts: files dns myhostname [root@notas ~]# hostname -f notas [root@notas ~]# grep ^host /etc/nsswitch.conf hosts: files dns [root@notas ~]# hostname -f hostname: Name or service not known
Bug tickets must have version flags set prior to targeting them to a release. Please ask maintainer to set the correct version flags and only then set the target milestone.
Target release should be placed once a package build is known to fix a issue. Since this bug is not modified, the target version has been reset. Please use target milestone to plan a fix for a oVirt release.
[root@dhcp-10-187 ~]# hostnamectl set-hostname tee.local [root@dhcp-10-187 ~]# hostname -f hostname: Name or service not known [root@dhcp-10-187 ~]# grep hosts /etc/nsswitch.conf #hosts: db files nisplus nis dns hosts: files dns
Okay, I see that on CentOS/RHEL myhostname is not part of the default hosts nsswitch line. Adding it solves teh issue: # grep hosts /etc/nsswitch.conf hosts: files dns ## MODIFY nsswitch.conf # grep hosts /etc/nsswitch.conf hosts: files dns myhostname # hostname -f localhost # hostnamectl set-hostname too # hostname -f too We nowknow th cause. Lukas, in upstream Fedora myhostname is already used. Do you know if it's planned to also introduce this in RHEL?
We already append myhostname to the nsswitch.conf in %post section of our specfile.
Lukas, on a centos 7 host I don't see myhostname in /etc/nsswitch.conf
I am sorry but I don't know how I can help you, on all my rhel7 machines the myhostname is used. Maybe centos made some changes, or you are using an image where this was removed.
*** Bug 1334735 has been marked as a duplicate of this bug. ***
Created attachment 1158522 [details] Screenshot showing the nsswitch.conf status (no myhostname) after a minimal RHEL 7.2 installation. I did a clean minimal installation using the rhel-server-7.2-x86_64-boot.iso. Right after installation myhostname is missing from /etc/nsswitch.conf. Note: nsswitch.conf contains my hostname after running yum update and receiving an systemd update.
Moving this back to systemd according to comment 21.
So lets try this: /etc/nsswitch.conf is owned by glibc, maybe in rhel they could add there myhostname by default, which could be more reliant and we could drop the sed from our %post section.
(In reply to Lukáš Nykrýn from comment #24) > So lets try this: /etc/nsswitch.conf is owned by glibc, maybe in rhel they > could add there myhostname by default, which could be more reliant and we > could drop the sed from our %post section. Well, it would be interesting to know, _why_ it fails. Is there a /etc/nsswitch.conf.bak ? Does anaconda write /etc/nsswitch.conf? Would it be better in %posttrans? Does the scriptlet work?
I think the problem will be either in anaconda or that sed is not present at the point when the scriptlet is run. I was thinking about the posttrans as a second solution. But I still thinks that this is the preffered setup for rhel we should not add in in systemd scriplets.
Is there a /etc/nsswitch.conf.bak ? Yes It does not look like anaconda is writing nsswitch.conf. But maybe some other component is rewriting it after systemd touched it.
It can actually be authconfig which is overwriting nsswitch.conf.
Tomas, can you imagine a flow where myhostname could be dropped from the hosts line?
Authconfig does not support myhostname in nsswitch.conf in RHEL-7. That support was added later in Fedora only.
Ah, so we finally found the root cause :) Tomas, can this patch get backported to RHEL 7.2.z?
Created attachment 1159048 [details] Screenshot illustrating the oVirt problem Just for reference (because I'll have forgotten about this in 2days): The problem is that the own hostname can not be resolved during hosted-engine-setup.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2016-2462.html