[Bug 440809] New: Can't change hostname with the 'hostname' command
https://bugzilla.novell.com/show_bug.cgi?id=440809 Summary: Can't change hostname with the 'hostname' command Product: openSUSE 11.1 Version: Beta 3 Platform: i686 OS/Version: openSUSE 10.3 Status: NEW Severity: Normal Priority: P5 - None Component: Network AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: gfarrell@netspeed.com.au QAContact: qa@suse.de Found By: Community User Created an attachment (id=249229) --> (https://bugzilla.novell.com/attachment.cgi?id=249229) Detailed notes showing the output of various commands re 'hostname'. Problem: hostname 'linux' persists despite attempts to rename it to something else. When trying to change the hostname, it is not changed in all places that rely on definition of the hostname for system purposes. Changing it in YaST Network Services succeeds in changing /etc/HOSTNAME and the 127.0.0.2 entry in /etc/hosts, but not for the first field of the 127.0.0.1 entry, nor for the 'hostname' line in /etc/NetworkManager/nm-system-settings.conf. Changing it with the 'hostname' command results in changes to /etc/HOSTNAME, but not to /etc/hosts or etc/NetworkManager/nm-system-settings.conf. The result is confusion within the system, where attempts to see what hostname is set will produce different results. For example, the 'hostname' command will show what it has been changed to ('MyHost.MyNetwork', say), as will the contents of /etc/HOSTNAME, but starting a console will show the prompt as 'user@linux:~>'. Any changes made are reset by rebooting the machine, whereupon the hostname 'linux' is resurrected. That is, the output of the hostname command is 'linux', even though the contents of /etc/HOSTNAME is still 'MyHost.MyNetwork'. It seems that NetworkManager's use of a hostname in the nm-system-settings.conf file is new, as is the format of the 127.0.0.1 line in /etc/hosts, but these two changes have not been coordinated well. To fix this hostname problem, one of two courses of action could be taken, followed by a third: a. If NetworkManager is to rely on its own config file for the hostname setting, then: (1) the 'hostname' command should be modified to alter the /etc/NetworkManager/nm-system-settings.conf file, as well as the /etc/HOSTNAME file; and (2) YaST Network Settings should save its 'hostname' setting to the /etc/NetworkManager/nm-system-settings.conf file, as well as the first hostname field of the 127.0.0.1 entry in /etc/hosts. *Or* b. NetworkManager could just refer to /etc/HOSTNAME, which exists precisely for the purpose of defining just that! YaST Network Settings would still need to save its 'hostname' setting to the first hostname field of the 127.0.0.1 entry in /etc/hosts. c. In addition to 'a' or 'b' above, maybe the 'hostname' command could also be modified to change the first hostname field of the 127.0.0.1 entry in /etc/hosts. This is for an installation on a hard drive partition from openSUSE-11.1-Beta3-KDE4-LiveCD-i386.iso; network is set up using NetworkManager, not ifup. Detailed notes are in the attachment. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=440809
User gfarrell@netspeed.com.au added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c1
--- Comment #1 from Geoff Farrell
https://bugzilla.novell.com/show_bug.cgi?id=440809
Andreas Jaeger
https://bugzilla.novell.com/show_bug.cgi?id=440809
User tambet@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c2
Tambet Ingo
https://bugzilla.novell.com/show_bug.cgi?id=440809
User tambet@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c3
Tambet Ingo
https://bugzilla.novell.com/show_bug.cgi?id=440809
User tambet@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c4
Tambet Ingo
https://bugzilla.novell.com/show_bug.cgi?id=440809
User tambet@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c5
Tambet Ingo
https://bugzilla.novell.com/show_bug.cgi?id=440809
User tambet@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c6
Tambet Ingo
https://bugzilla.novell.com/show_bug.cgi?id=440809
User tambet@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c7
--- Comment #7 from Tambet Ingo
https://bugzilla.novell.com/show_bug.cgi?id=440809
User aj@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c8
Andreas Jaeger
https://bugzilla.novell.com/show_bug.cgi?id=440809
User tambet@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c9
--- Comment #9 from Tambet Ingo
https://bugzilla.novell.com/show_bug.cgi?id=440809
User tambet@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c10
Tambet Ingo
https://bugzilla.novell.com/show_bug.cgi?id=440809
User gfarrell@netspeed.com.au added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c11
--- Comment #11 from Geoff Farrell
To use dynamic hostname (ie, update it from DHCP, PPP, ...), set DHCLIENT_SET_HOSTNAME=yes in /etc/sysconfig/network/dhcp.
I wouldn't want to do that, because of the warning in /etc/sysconfig/network/dhcp:
# Should the DHCP client set the hostname? (yes|no) # # When it is likely that this would occur during a running X session, # your DISPLAY variable could be screwed up and you won't be able to open # new windows anymore, then this should be "no".
I am happy that my current hostname setting is sent automatically:
# By default the current hostname is sent ("AUTO"), if one is defined in # /etc/HOSTNAME. # Use this variable to override this with another hostname, or leave empty # to not send a hostname. # DHCLIENT_HOSTNAME_OPTION="AUTO"
The difficulty here is that if I have changed my hostname with the 'hostname' command, it won't have changed in /etc/HOSTNAME, as the command currently works.
Fixed in beta5. I removed the hacks from /etc/NetworkManager/nm-system-settings.conf and implemented monitoring of /etc/HOSTNAME.
That's a good move as far as NetworkManager's configuration goes, but it doesn't solve my problem.
Problem: hostname 'linux' persists despite attempts to rename it to something else.
The issue is that no one tool available to the user changes the hostname in all the places referenced by various programs: 1. /etc/HOSTNAME 2. /etc/hosts 3. /proc/sys/kernel/hostname The 'hostname' command affects only /proc/sys/kernel/hostname. The remaining two locations can be edited manually, but a re-boot is required to effect the changes throughout the system (or alternatively, re-start the X-server and the network service). This is not a suitable solution, especially for inexperienced users. The GUI tool (YaST-> Network Devices-> Network Settings) is able to change all three locations, but when NetworkManager is in control, the user is warned off using YaST for any purpose except changing the method to 'ifup'. For example, the hostname settings are ghosted and can not be edited. I have seen in bug #444967 the policy re changing network settings (that YaST should not change network settings when NetworkManager is in control) and agree with the logic. In an effort to provide a solution to this bug, I wrote a simple script (attached) that could be used to change the hostname in those three files listed above. It's not an acceptable long-term solution, but it might save having to re-write YaST to counter NetworkManager's present deficiency in time for a 11.1 release. Maybe all that would be needed is a Release Note pointing users to the script (suggest /bin/change-hostname) if they need to change the hostname following installation. In this light, I request that this bug be re-opened, and my suggested resolution be examined. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=440809
User gfarrell@netspeed.com.au added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c12
--- Comment #12 from Geoff Farrell
https://bugzilla.novell.com/show_bug.cgi?id=440809
User tambet@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c13
--- Comment #13 from Tambet Ingo
https://bugzilla.novell.com/show_bug.cgi?id=440809
User kmachalkova@novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c14
--- Comment #14 from Katarina Machalkova
https://bugzilla.novell.com/show_bug.cgi?id=440809
User gfarrell@netspeed.com.au added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c15
--- Comment #15 from Geoff Farrell
NM notices the change and updates /etc/hosts and calls hostname (which modifies /proc/sys/kernel/hostname).
That's not what I see in Beta5, and I've just checked RC1, and it's the same. For a start, NetworkManager does nothing with a hostname change when the network is restarted (rcnetwork restart). Even though /etc/HOSTNAME has changed, /etc/hosts and /proc/sys/kernel/hostname remain unchanged after a network restart. With a reboot, NetworkManager notices the change and sets /proc/sys/kernel/hostname (by the 'hostname' command), but it doesn't change /etc/hosts. Its 127.0.0.2 line retains the randomly allocated 'linux-0mh9.site linux-0mh9' setting. So the programs that rely on /etc/hosts to get the hostname will get the wrong one. Maybe my suggested 'change-hostname' script doesn't need to apply the 'hostname' command in it (however, I can't see any harm in doing that) but RC1 still shows that it needs changes applied to /etc/hosts and /etc/HOSTNAME for a complete treatment of the problem, as it stands. Also, the Release Notes would have to mention that a reboot is necessary following running of the script. I still think that something should be done about this; I don't think it's wise to leave it in this state. The attached file shows detailed steps showing hostname changes for RC1. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=440809
User gfarrell@netspeed.com.au added comment
https://bugzilla.novell.com/show_bug.cgi?id=440809#c16
--- Comment #16 from Geoff Farrell
participants (1)
-
bugzilla_noreply@novell.com