Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to change the hostname to host01 on an instance that was is using the RightImage_CentOS_5.4_x64_v5.6 - 11H2.a1 [rev 11] MCI.

So I set the /etc/hosts file to:

127.0.0.1 localhost localhost.localdomain  
10.76.249.192 host01  

and set the /etc/sysconfig/network file:

HOSTNAME=host01

and rebooted.

After the reboot, everything looks good. The hostname is changed:

$ /bin/hostname
host01

However, a new file appeared in the system /etc/hostname with, the following content:

ip-10-76-249-192

The /etc/hosts host file looks like this:

127.0.0.1 localhost localhost.localdomain  
10.76.249.192 host01  
10.76.249.192 ip-10-76-249-192.ec2.internal ip-10-76-249-192  

After reboot, if I drop into an other user, the hostname will change back:

$ hostname
ip-10-76-249-192  

Does anybody has any idea why this is happening and how stop this?

share|improve this question
    
Is there anything in /var/log/audit? –  Bart De Vos Jun 11 '11 at 9:01

1 Answer 1

Rightscale's FAQ recommends you use an rc script to change the hostname using the hostname command.

http://support.rightscale.com/06-FAQs/FAQ_0073_-_How_can_I_change_the_EC2_hostname%3F

share|improve this answer
    
The problem is that hostname command only changes until the system is rebooted. –  tmx Jun 11 '11 at 19:07
    
Which is part of the recommendation, if you use the /etc/rc.local startup script it will reset itself post install after the Rightscale/EC2 auto name change occurs. There will be a brief moment where it would be set to the dynamic name, but then it will revert just as the init scripts complete. –  Ori Jun 11 '11 at 20:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.