Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.
[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?

share|improve this question

1 Answer 1

up vote 4 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 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...

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

 
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.