Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

The problem is that I fail to SSH to a remote machine via its hostname, while using its IP works.

The hostname returned by command hostname is: california_desert while the name returned by command nslookup $IP_address is: pcpp3238782. They did not match each other.

I think that's why I cannot connect to remote machine using its hostname.

I have checked /etc/hosts, /etc/hostname, /etc/sysconfig/network: all set the hostname to california_desert.

Checked with /etc/resolve.conf, the name server is set to the right one.

Also tried strace but no new clue.

Anybody can please help?

share|improve this question
seems the issue can not resolve on local machine but to refresh DNS server, right? – California_desert Sep 7 '12 at 8:32
No, you would need to contact the DNS server administrator and announce that computer known as pcpp3238782 should be rather called california_desert. – Paweł Rumian Sep 7 '12 at 11:51
Yes, that's correct way, thank you buddy! – California_desert Sep 7 '12 at 13:43
up vote 3 down vote accepted

The problem here is that the hostname and hosts files are only used for the computer they're on. In order for other computers to be able to use the hostname, it needs to be in the DNS zone for the domain.

Think of it like this - you get a phone, and it has a phone number 555-5555. You now know that to call California_desert, you need to dial 555-5555. But nobody else knows this. In order for others to know how to reach you, you need to register your phone number in the directory. DNS is that directory service.

Of course, you can also tell a friend that your number is 555-5555 and then they can call you directly without looking it up in the directory. For a unix system, this would be like adding the hostname and ip for California_desert to the hosts file on every server that wants to connect to it.

share|improve this answer
A more easier solution is to install a Zeroconf software like avahi on all computers. Then each computer announce its hostname automatically and can be pinged under TheHostname.local. – jofel Sep 7 '12 at 12:22
Thanks for your clear&detailed explanation, very helpful! – California_desert Sep 7 '12 at 13:40

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.