LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   CentOS 4.4 Changing hostname Problem (https://www.linuxquestions.org/questions/linux-software-2/centos-4-4-changing-hostname-problem-635313/)

Rush_898 04-14-2008 01:20 PM

CentOS 4.4 Changing hostname Problem
 
The specific hostnames have been changed for your protection :).


I have changed the 3 locations I know for a redhat host. Here are some results on this system:
Quote:

$ cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.x.x.x NEWhostname.site.domain NEWhostname
192.x.x.x NEWhostname.site.domain NEWhostname

$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME="NEWhostname"
GATEWAY=x.x.x.1

$ cat /etc/hostname
NEWhostname.site.domain
All that is set to the NEWhostname, however the command "hostname" returns the old hostname. I have tried restaring multiple times. If I manually run the command "hostname NEWHOST" and I run "hostname" it will return correctly "NEWHOST". However, my prompt does not change and when I reboot it reverts to OLDhostname.

Quote:

$ hostname
OLDhostname.storefinancial.net

Distro info:

me@OLDhostname ~ $ cat /etc/issue
CentOS release 4.4 (Final)
Kernel \r on an \m



I hope there is a simple fix I am missing, as I am quite confused. Thanks for any help.

DotHQ 04-14-2008 01:23 PM

Once you reboot the new hostname will show up.
You only had to change the /etc/sysconfig/network file and that does it. Hosts file still needs updated though.

To change the hostname for this session without rebooting do a:
hostname newhostname.fully.qualified.name.com

That works until the machine is rebooted. But once rebooted it will pick up the name from the /etc/sysconfig/network file. So you'll be good to go. :D

Rush_898 04-14-2008 01:48 PM

As god is my witness that is not working. This is my /etc/sysconfig/network file:

NETWORKING=yes
HOSTNAME=nagios001
GATEWAY=10.x.x.x


When I reboot it is the same old hostname is was before, but now I have no idea where it could even be pulling it from. I wish I was making this up.

DotHQ 04-14-2008 02:12 PM

Can you set the hostname via the command line:
hostname newhostname

Does that work?

DotHQ 04-14-2008 02:14 PM

Warning, silly question coming .......

How do you know it's the same old hostname ...in otherwords where do you see the old hostname? It's not in your prompt or something like that is it?

Rush_898 04-14-2008 02:19 PM

Quote:

Originally Posted by DotHQ (Post 3121111)
Warning, silly question coming .......

How do you know it's the same old hostname ...in otherwords where do you see the old hostname? It's not in your prompt or something like that is it?

Yes, the old hostname shows up as my prompt, and when I do a "hostname" command after a reboot it is the old FQDN. Where it is getting it from I do not know.


The "hostname NEWHOST" command will not change my prompt, but if I issue it and then just "hostname" it does show the correct NEWhostname. It does not however persist through a reboot.

I appreciate your help.

I tried this as well:

echo "newhost" > /proc/sys/kernel/hostname


but with a reboot it was unsuccessful as well.

DotHQ 04-14-2008 02:24 PM

I hate to go this route, but I have seen systems where, when the hostname was set via the gui you have to get back into the gui to change it. It must be hiding somewhere.
My suggestion is to go into the gui / network settings and change the hostname there. Maybe that will appease the gods. Good luck.

Brian1 04-14-2008 03:58 PM

Possible thoughts of change is in /etc/bashrc or /etc/rc.local

Brian


All times are GMT -5. The time now is 01:02 AM.