Solution of the Error
Step 1: Check permission on /etc/hosts
Note that you need read permission of all users.
Step 2: Check the contents of /etc/hosts
Open the contents of /etc/hosts and check the contents inside it.
$ less /etc/hosts
Note that the contents of this files follow following format.
A simple example,
Step 3: Check the hostname and make sure you can ping your hostname.
$ hostname
dhcppc2
$ ping database
PING dhcppc2 (192.168.1.4) 56(84) bytes of data.
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=0 ttl=64 time=0.038 ms
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=1 ttl=64 time=0.000 ms
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=3 ttl=64 time=0.000 ms
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=4 ttl=64 time=0.041 ms
If you get the following message,
$ ping database
ping: unknown host database
then possibly you will hit above bug.
And you need to modify /etc/hosts files. In the alias section you can give the name of your machine name. If your machine name is "dhcppc2" you can give /etc/hosts entry as,
And then ping database again. Make sure you are able to ping your host.
Step 4: Diagnosis DNS problem if you have DNS setup
If you have DNS setup, ping is not a tool to diagnose DNS problem. A better tool to use is nslookup, dnsquery, or dig.
$nslookup www.google.com
The forward and reverse lookup should succeed.
Step 5: Check nsswitch.conf
Make sure host lookup is also done through the /etc/hosts file and not just dns. The keyword files should come before dns.
Step 6: Check resolv.conf
nameserver 125.22.47.125
nameserver 202.56.250.5
Make sure nameserver with DNS name is added there.
Step 1: Check permission on /etc/hosts
$ ls -l /etc/hosts
-rw-r--r-- 1 root root 153 Nov 24 2007 /etc/hosts
Note that you need read permission of all users.
Step 2: Check the contents of /etc/hosts
Open the contents of /etc/hosts and check the contents inside it.
$ less /etc/hosts
Note that the contents of this files follow following format.
IP Address fully qualified hostname simple or short hostname Alias
A simple example,
$ cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 192.168.1.4 dhcppc2 localhost.localdomain localhost
Step 3: Check the hostname and make sure you can ping your hostname.
$ hostname
dhcppc2
$ ping database
PING dhcppc2 (192.168.1.4) 56(84) bytes of data.
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=0 ttl=64 time=0.038 ms
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=1 ttl=64 time=0.000 ms
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=3 ttl=64 time=0.000 ms
64 bytes from dhcppc2 (192.168.1.4): icmp_seq=4 ttl=64 time=0.041 ms
If you get the following message,
$ ping database
ping: unknown host database
then possibly you will hit above bug.
And you need to modify /etc/hosts files. In the alias section you can give the name of your machine name. If your machine name is "dhcppc2" you can give /etc/hosts entry as,
192.168.1.4 dhcppc2 localhost.localdomain localhost
And then ping database again. Make sure you are able to ping your host.
Step 4: Diagnosis DNS problem if you have DNS setup
If you have DNS setup, ping is not a tool to diagnose DNS problem. A better tool to use is nslookup, dnsquery, or dig.
$nslookup www.google.com
The forward and reverse lookup should succeed.
Step 5: Check nsswitch.conf
$ cat /etc/nsswitch.conf hosts: files dns
Make sure host lookup is also done through the /etc/hosts file and not just dns. The keyword files should come before dns.
Step 6: Check resolv.conf
$ cat /etc/resolv.conf; generated by /sbin/dhclient-script
nameserver 125.22.47.125
nameserver 202.56.250.5
Make sure nameserver with DNS name is added there.
Excellent post ...
ReplyDeleteThank you very much.