I have an Ubuntu server called crow:

$ hostname
crow

But when I try to ping it (from itself), I get unknown host:

$ ping crow
ping: unknown host crow

This is despite explicitly adding crow to /etc/hosts:

$ sudo cat /etc/hosts
127.0.0.1       localhost crow

What am I doing wrong?

Additional info in response to comments:

The hosts line of /etc/nsswitch.conf looks like this:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
link|improve this question

36% accept rate
Have you rebooted/restarted networking services after making the edit to your hosts file? – BloodPhilia Feb 2 '11 at 16:50
3  
Modification of hosts file doesn't require restart of network services. – Sameer Feb 2 '11 at 17:20
2  
What does the hosts line in /etc/nsswitch.conf look like? – David Mackintosh Feb 2 '11 at 17:44
where do you ping it, from the server itself or from another machine in the same lan? – Nicola Boccardi Feb 2 '11 at 19:04
I've edited to answer these questions – sanity Feb 2 '11 at 19:29
feedback

1 Answer

up vote 3 down vote accepted

Check permissions on /etc/hosts and /etc/nsswitch.conf files. They should be world-readable.

link|improve this answer
Indeed, there should be no need for sudo in sudo cat /etc/hosts. – hlovdal Feb 2 '11 at 21:04
That fixed it, thanks! – sanity Feb 2 '11 at 21:20
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.