I have a redhat (EL5) server that I need to change the hostname on. I'm trying to put it back into a known state to help with server provisioning activities.
As part of changing the hostname, I'm updating /etc/sysconfig/network and /etc/hosts. I also have an explicit call to hostname. My desired state is that the server thinks its hostname is "localhost". And a call to "hostname" returns "localhost".
The problem I'm having is that when I reboot, the hostname is reverted to "localhost.companyname.com" which is not what I want. How do I ensure that the hostname is set up as just "localhost" when I reboot?
My /etc/sysconfig/network file contains:
NETWORKING=yes
HOSTNAME=localhost
GATEWAY=123.123.123.123 #I do have a proper IP address here
My /etc/hosts file contains:
127.0.0.1 localhost.localdomain localhost
172.21.1.1 localhost.companyname.com localhost
-
- Change the ^HOSTNAME line in /etc/sysconfig/network
- Change the hostname (FQDN and alias) in /etc/hosts
- Run /bin/hostname new_hostname for the hostname change to take effect immediately.
- Run /sbin/service syslog restart for syslog to log using the new hostname.
A reboot is not required to change the system hostname, of course you should reboot in order to verify your issue is solved :)
More information at http://kbase.redhat.com/faq/docs/DOC-8646
NOTE:
Your error is in the second line of/etc/hosts
! just remove it.McJeff : And some apps pull the host name at startup and not again. Rebooting is a good way to restart everything at once.Rodger : service --full-restart will accomplish that without a reboot, although at that point you might as well.From AlberT -
Can't say that naming your server localhost is the wisest course of action.
From Tux
0 comments:
Post a Comment