2
[root@data001 etc]# hostname
data001.dd
[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?

DD.
  • 3,114
  • 11
  • 35
  • 50
  • 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 07 '15 at 22:30

1 Answers1

7

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 127.0.1.1 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 127.0.0.1 instead of 127.0.1.1 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

etc...

stew
  • 9,388
  • 1
  • 30
  • 43
  • 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 07: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