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.

Every time I boot, CentOS 6.0 Server hostname disappears. I have to re-issue hostname command to reset it.

Please help!

share|improve this question

2 Answers 2

up vote 8 down vote accepted

you need to set your host name properly in /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=localhost
DOMAIN=localdomain
GATEWAY=yourgatewayaddress
share|improve this answer
    
Works! Wonder how the network file got updated automatically?! I remember putting the correct fqdn while installation!!! Thanx a lot! –  Anshuman Mar 22 '12 at 14:12
    
not a problem glad to help. For some reason it does this on some of my servers too on a fresh install, dont have the time to look into why.. i just make it practice to check this after the install completes before i do the rest of the server configuration, a 2 second check :) Could be something to do with SELinux, but wouldnt like to say for sure :) –  LloydOliver Mar 22 '12 at 14:23
    
@JDI Can I do this via some kind of one-liner? –  Nickolai Leschov Apr 2 at 23:39

Add a line

HOSTNAME=your.hostname.tld

to the /etc/sysconfig/network file to set the hostname to your.hostname.tld

share|improve this answer
1  
I think you typically do not want the FQDN here, instead you want the short hostname. The domain should be present in /etc/resolv.conf and, optionally, in a DOMAIN= variable in the same file. –  Kyle Smith Mar 22 '12 at 13:34
1  
@KyleSmith: No, you would normally put the fqdn here for both CentOS 6 and CentOS 5. No mention of a DOMAIN setting in either document either. –  Iain Mar 22 '12 at 14:08
    
Works! I put the whole fqdn in the network file. Will try what you are suggesting too! For now, issue resolved. I'm new to Linux and these small things frustrate a lot :-P Thanx!!!! –  Anshuman Mar 22 '12 at 14:14
    
@Iain, can you point me to the documentation you're looking at. Maybe I'm doing it wrong :) –  Kyle Smith Mar 22 '12 at 15:27
    
@KyleSmith: I did, the links are CentOS 6 and Centos 5 above –  Iain Mar 22 '12 at 15:57

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.