RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1356188 - /etc/hostname change no longer takes effect immediately
Summary: /etc/hostname change no longer takes effect immediately
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: NetworkManager
Version: 7.3
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Beniamino Galvani
QA Contact: Desktop QE
URL:
Whiteboard:
: 1359222 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-13 15:29 UTC by Scott Poore
Modified: 2017-07-13 20:25 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-13 20:25:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Scott Poore 2016-07-13 15:29:34 UTC
Description of problem:

In RHEL7.2 and earlier, it seems as if updating /etc/hostname changed the hostname immediately.  Now it does not.  I have to either run hostname or hostnamectl command.

Is this a documented change in behavior?  Or was this maybe a fix of a bug in the old version? 

Example of what I'm seeing in additional info.

Version-Release number of selected component (if applicable):
systemd-219-23.el7.x86_64

How reproducible:
always as far as I can tell.

Steps to Reproduce:
1.  echo "<new hostname>" > /etc/hostname
2.  hostname

Actual results:
shows same hostname

Expected results:
used to show new/changed hostname

Additional info:

------------ [ rhel7.2 ] -----------------------

rhel_7.2_vm # hostname
vm3.example.com
rhel_7.2_vm # cat /etc/hostname
vm3.example.com
rhel_7.2_vm # echo newhostname > /etc/hostname
rhel_7.2_vm # hostname
newhostname
rhel_7.2_vm # rpm -q systemd
systemd-219-19.el7.x86_64

------------ [ rhel7.3 ] -----------------------
rhel_7.3_vm # hostname
rhel7-3.example.com
rhel_7.3_vm # cat /etc/hostname
rhel7-3.example.com
rhel_7.3_vm # echo newhostname > /etc/hostname
rhel_7.3_vm # hostname
rhel7-3.example.com
rhel_7.3_vm # sleep 60
rhel_7.3_vm # hostname
rhel7-3.example.com
rhel_7.3_vm # hostnamectl
   Static hostname: newhostname
Transient hostname: rhel7-3.example.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 71a559c395354fe6977d702cba94da9d
           Boot ID: fcb10e5ea4d34b17ae04c942c23f7ab6
    Virtualization: kvm
  Operating System: Red Hat Enterprise Linux Server 7.3 Beta (Maipo)
       CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:beta:server
            Kernel: Linux 3.10.0-467.el7.x86_64
      Architecture: x86-64
rhel_7.3_vm # hostname
newhostname
rhel_7.3_vm # hostnamectl
   Static hostname: newhostname
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 71a559c395354fe6977d702cba94da9d
           Boot ID: fcb10e5ea4d34b17ae04c942c23f7ab6
    Virtualization: kvm
  Operating System: Red Hat Enterprise Linux Server 7.3 Beta (Maipo)
       CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:beta:server
            Kernel: Linux 3.10.0-467.el7.x86_64
      Architecture: x86-64

Comment 2 Lukáš Nykrýn 2016-07-14 06:58:00 UTC
From systemd point of view this is a configuration file which tells what hostname should be set during boot.
There must be something else that watches it and change the hostname in kernel and my suspect is Network Manager:

[root@old ~]# hostname
old
[root@old ~]# echo myold > /etc/hostname 
[root@old ~]# hostname
old
[root@old ~]# systemctl start NetworkManager
[root@old ~]# hostname
myold
[root@old ~]# echo old > /etc/hostname 
[root@old ~]# hostname
old

Comment 3 Lukáš Nykrýn 2016-07-14 07:03:50 UTC
čec 14 08:33:36 old NetworkManager[955]: <info>  Setting system hostname to 'myold' (from system configuration)
čec 14 08:33:47 old NetworkManager[955]: <info>  Setting system hostname to 'old' (from system configuration)
čec 14 08:33:57 old NetworkManager[955]: <info>  Setting system hostname to 'myold' (from system configuration)
čec 14 08:34:09 old NetworkManager[955]: <info>  Setting system hostname to 'old' (from system configuration)
čec 14 08:35:07 old NetworkManager[955]: <info>  Setting system hostname to 'myold' (from system configuration)
čec 14 08:35:16 old NetworkManager[955]: <info>  Setting system hostname to 'old' (from system configuration)
čec 14 08:50:12 myold NetworkManager[955]: <info>  Setting system hostname to 'myold' (from system configuration)
čec 14 08:50:13 myold NetworkManager[955]: <info>  Setting system hostname to 'old' (from system configuration)

Comment 4 Scott Poore 2016-07-14 18:27:32 UTC
FYI, from the hosts I'm testing on, I see these versions:

-------------- rhel7.3 ---------------------

NetworkManager-1.4.0-0.3.git20160621.072358da.el7.x86_64

-------------- rhel7.2 ---------------------

NetworkManager-1.0.6-27.el7.x86_64

I do see NetworkManager running on both.

Comment 5 Beniamino Galvani 2016-07-18 09:43:54 UTC
AFAIK all the RHEL documentation suggests to use hostnamectl or
nmcli/nmtui to change the system hostname, and writing /etc/hostname
directly to do so only worked in RHEL 7.2 because we used to monitor
changes to the file to detect when hostnamectl updated the hostname;
but in this way we also caught manual changes to the file.

Now we monitor hostnamectl properties on D-Bus to detect a change of
the hostname and thus writing the file doesn't have effect on the
system hostname.

In my opinion this is correct as a change to the file should not
reconfigure automatically the system. It's also consistent with
hostnamed/hostnamectl (which doesn't pick up changes to the file).
All changes should go through either hostnamed or nmcli/nmtui.

Comment 6 Scott Poore 2016-07-18 12:40:02 UTC
Ok, that explains the change in behavior.  Should this be documented somewhere in 7.3 release notes or one of the guides?

Thanks,
Scott

Comment 7 Lukáš Nykrýn 2016-07-26 11:32:11 UTC
*** Bug 1359222 has been marked as a duplicate of this bug. ***

Comment 8 Beniamino Galvani 2017-07-13 20:25:14 UTC
This was documented in RHEL 7.3 Release Notes:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/7.3_Release_Notes/new_features_networking.html

and in the Networking Guide.


Note You need to log in before you can comment on or make changes to this bug.