DNS problem : ping doesn't recognize hostname

I have vmware on my windows PC ( hostname : acer ).
vmware has RHEL 7 ( hostname : rhel7 ) installed recently.

RHEL IP configuration
IP : 192.168.5.128
Netmask : 255.255.255.0

ssh to rhel7 works from acer using putty

resolve.conf

cat /etc/resolv.conf
nameserver 192.168.5.1

host file of acer has the entry

192.168.5.1 acer

ping to acer from rhel 7 does not work.

[root@rhel7 ~]# ping acer
ping: unknown host acer

So is acer the DNS server? That's what resolv.conf is configured as.

Your ping failure indicates that either there's no route to the DNS server (192.168.5.1), the DNS service is not running on that server, or the DNS service does not know about acer.

What happens if you

#ping 192.168.5.1

from RHEL?

Your entry in /etc/hosts on RHEL for acer should allow it to resolve the name acer within the RHEL OS without reference to the DNS server.

That should be the host file on rhel7 as a fallback in case the name service call fails.

ping to 192.168.5.1 from RHEL works

[root@rhel7 ~]# ping 192.168.5.1
PING 192.168.5.1 (192.168.5.1) 56(84) bytes of data.
64 bytes from 192.168.5.1: icmp_seq=1 ttl=64 time=0.588 ms
64 bytes from 192.168.5.1: icmp_seq=2 ttl=64 time=0.566 ms
64 bytes from 192.168.5.1: icmp_seq=3 ttl=64 time=0.829 ms
^C
--- 192.168.5.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.566/0.661/0.829/0.119 ms
[root@rhel7 ~]#

The host PC ( windows - acer ) where VM is installed maintains the list of hostname and ips in its host file. As such it is not a "so called DNS server", but since it maintains the list in host file and 192.168.5.1 is specified as name server then my understanding is that it should search in the host file of acer ( 192.168.5.1)

As per your recommendation I have added acer in the host file of RHEL.
RHEL host file now looks like.

[root@rhel7 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.5.1     acer
192.168.5.128   rhel7
[root@rhel7 ~]#

Now the ping using hostname works fine

[root@rhel7 ~]# ping acer
PING acer (192.168.5.1) 56(84) bytes of data.
64 bytes from acer (192.168.5.1): icmp_seq=1 ttl=64 time=0.523 ms
64 bytes from acer (192.168.5.1): icmp_seq=2 ttl=64 time=0.653 ms
64 bytes from acer (192.168.5.1): icmp_seq=3 ttl=64 time=0.608 ms
^C
--- acer ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.523/0.594/0.653/0.060 ms
[root@rhel7 ~]#

But I have one more entry of ubuntu in host file of acer ( 192.168.5.1 ) . Host file of acer looks like

192.168.5.1      acer
192.168.5.128 rhel7
192.168.5.129 ubuntu15

ping to ubuntu does not work from rhel7

[root@rhel7 ~]# ping ubuntu15
ping: unknown host ubuntu15
[root@rhel7 ~]#

So - what would you infer from these facts?

Thanks Rudi for the reply.

I think somehow rhel is not able to contact acer when name resolution is required.
Some how rhel is not able to findout which is the name server ?
Do you have any clue what can be the reason ?

1) How did you manage to ping acer ?
2) Sure acer is a name server?

I entered acer ( ip and hostname ) in host file of rhel.

As I mentioned, acer maintains list of host name entry in the host file.
acer is a vmware windows host whereas rhel is installed as a vitual machine in vmware

So - why don't you enter ubuntu15 plus IP into the host file?

All of this does NOT mean acer is a name server. Try to find the REAL name server(s), be it in the files on acer , be it on e.g. your router.

Remember that ping often uses gethostbyname system/kernel call where traceroute often uses the actual DNS lookup. You can also easily test whether the entries are indeed in DNS by using nslookup or dig

Hello

I believe that 192.168.5.1 is your Acer windows PC, and there is no DNS server on it, which are you relies to.
You'll need to set some other DNS server for your Linux server in resolf.conf, for example 8.8.8.8 (Google DNS server).

If you need to be able ping your Acer PC by name from Linux server, you can add this line at /etc/hosts:

192.168.5.1 acer

I think that you might need to improve your knowledge about DNS a little, this article can help a bit.

Refresh your setting to resolve DNS issue in your computer. Go to network adapter setting and do disable and again enable. For more see my logic at

Yes, ping (and traceroute) use gethostbyname() for resolving hostnames. And gethostbyname() goes to /etc/nsswitch.conf that must have the line

hosts: files dns

to consider first /etc/hosts then DNS.