1

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

Please help!

2 Answers 2

9

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

NETWORKING=yes
HOSTNAME=localhost
DOMAIN=localdomain
GATEWAY=yourgatewayaddress
3
  • Works! Wonder how the network file got updated automatically?! I remember putting the correct fqdn while installation!!! Thanx a lot!
    – Anshuman
    Mar 22, 2012 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 :) Mar 22, 2012 at 14:23
  • @JDI Can I do this via some kind of one-liner? Apr 2, 2014 at 23:39
4

Add a line

HOSTNAME=your.hostname.tld

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

12
  • 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, 2012 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.
    – user9517
    Mar 22, 2012 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, 2012 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, 2012 at 15:27
  • @KyleSmith: I did, the links are CentOS 6 and Centos 5 above
    – user9517
    Mar 22, 2012 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .