Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
[root@data001 etc]# hostname
[root@data001 etc]# ping data001.dd
ping: unknown host data001.dd
[root@data001 etc]#

How do I fix this? This is on a fresh Centos6 build...does this not come configured by default?

share|improve this question
I'm puzzled by this too and would love to understand why CentOS is (under some circumstances) not able to correctly configure that on setup. We're talking about early 1980's problems here. – Florian Heigl Aug 7 '15 at 22:30
up vote 7 down vote accepted

edit /etc/sysconfig/network and change the HOSTNAME setting to say data001 instead of data001.dd. Edit /etc/hosts and make sure you have a line data001.dd data001. If you already have such a line, make sure that data001.dd is the first thing after the ip address. Doing this with instead of is also common, valid, and acceptable. Don't remove localhost from that line, if it exists.

After you are done, all these should work:

getent hosts data001.dd
getent hosts data001
ping data001.dd
hostname --fqdn
ping localhost


share|improve this answer
I dont have any file /etc/hostname. Do I have to change this everytime I change the hostname using the command hostname? – DD. May 16 '12 at 15:53
Why are you asking about /etc/hostname? stew hasn't mentioned that file at all. – joechip May 16 '12 at 18:13
@joechip oops, I was mentioning it, and updated it to match his centos box. I thought I had commented here when I edited, but it seems I failed to. – stew May 16 '12 at 18:13
@stew why do I need to change the hostname from data001.dd to data001? – DD. May 17 '12 at 7:47
you don't have to. though it seems pointless to me to have hostname return fully qualified when that is a job for hostname --fqdn – stew May 17 '12 at 15:56

Your Answer


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.