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.

I just set up a CentOS 5.5 machine on my local network and attempted to modify the hostname by editing /etc/sysconfig/network file. When I'm logged in locally the change to the hostname is reflected and seems to be working fine. When I open a SSH session via PuTTY from Windows this is what I see at the prompt:

[root@? ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=mini.local
[root@? ~]# sysctl kernel.hostname
kernel.hostname = ?
[root@? ~]# hostname
?
[root@? ~]# hostname -f
hostname: Unknown server error

A couple of other symptoms that may be helpful in troubleshooting this problem. I can ping the CentOS box from my Windows machine via IP but not hostname. Also, my Netgear router does not display the hostname when I view the "Connected Devices", I do see the mac address and the proper IP listed though.

How can I make it so that the hostname is properly propagated throughout my network?

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

You need a DNS or setting the hosts file on every machine in your LAN.

share|improve this answer
    
can you explain or point me to some docs or whatever that explain why that is necessary for Linux but not for the Windows/MAC machines on the network? I thought my Netgear router would be performing the DNS function in this case... maybe that is a bad assumption? –  spoon16 Jun 1 '10 at 7:37
    
If your router serves as dhcp server, maybe it can also serves as dns. A simple alternative is dnsmasq (thekelleys.org.uk/dnsmasq/doc.html). Resolving ip addresses is not a system operative issue, but a network issue. –  lg. Jun 1 '10 at 7:57
    
@lg, centos/redhat is not my distro, but I would imagine that hostname and hostname -f should work regardless of DNS settings –  Unreason Jun 1 '10 at 8:35
add comment

In redhat you have to change the hostname in 2 places:

/etc/sysconfig/network
/etc/hosts

add a line in your hosts file with the ip and name written in sysconfig/network. I don't remember if you should reboot or not. Try with:

service network restart

share|improve this answer
    
I have changed the values in both of those places and still other machines on the LAN do not automatically recognize the name of the machine. I think that @lg is correct. Windows and MAC must be using something for dynamic name resolution that does not require a dedicated DNS server (WINS maybe?). –  spoon16 Jun 1 '10 at 10:10
add comment

first off get the hostname on the machine correct using this reference from the centos wiki

then you will need to setup a reverse dns record on your dns server (maybe this is your router but i dont think you can do this directly on home user netgears) for the network to reflect the hostname you have chosen for the machine

this might be of use to you commands wise but not for the dns settings, slicehost dns/email article

share|improve this answer
add comment

Just use system-config-network and set your hostname there.

share|improve this answer
add comment

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.