Kurakani Jobs Rooms Events Post Classifieds Login Register
To linux and devops gurus
Posts 16 · Viewed 4156 · Likes 7 · Go to Last Post
· Snapshot 0
Like · Likedby · 0
Linux gurus,
Hope you are enjoying your long weekends. Here is what I have:
How can I make sure I can ping the centos vms by hostname?
I have installed 2 Centos 6.7 in VMWareWork Statation. I can ping the IP addresses from one virtual machine to another virtual machine. I also can ping to the IP addresses of each vms from my local pc. In addition, I can ping to the same vm i.e. itself from its termina' either by ip address or by  hostname. However, I am not able to ping from one vm to another vm by the hostname. Also I cannot ping it from my local machine which runs wiindows.

Where should I be looking at to trouble shoot this issue?

Dhanyabad in advance.
Last edited: 08-Oct-17 07:37 PM
RESPONSES :: Showing All
· Snapshot 158
Like · Liked by · 1
Not a devops here but since there are no replies , let me try.

You need to make sure you have proper DNS infrastructure. DNS is used for ip to name translation. If you are trying for quick fix, google about host file, you can add entries there and make it work
· Snapshot 235
Like · Liked by · 1
Solution 1: Edit your hosts file on you local PC as admin

start --> CMD --> right click and run as admin --> cd drivers/etc --> notepad hosts --> add a line at the bottom describing your IP and hostname(alias). It should look like this:

192.168.78.xx (your Ip for VM) testVM(hostname)

save this file --> try pinging using hostname

Solution 2: modify your hosts file on VMs

from linux terminal --> vi /etc/hosts --> add IP of your another VM and hostname there

192.168.78.xx testVM1(hostname)

Hope this helps.
· Snapshot 281
Like · Liked by · 0
Hi Meraj and pkr_kancha,

Kudos to you ! I am able to ping the vms from each other by inputting the each others ip and host name in each other's host file. However, I am still not able to ping the vms by hostname yet from my local pc. I edited the host file of local pc by inputting the ip address and hostname.
while pinging by hostname, I get the error like 'Ping request could not find host vm(hostname). Please check the name and try again.'

ps. the network adapter setting for the vm in vmwareworkstation is set as NAT, not sure if this has anything to do with the ping from the local pc.  The other options are bridged, host only and custom in place of NAT

Where should I be looking further?
Last edited: 09-Oct-17 10:19 AM
Last edited: 09-Oct-17 10:21 AM
Last edited: 09-Oct-17 10:55 AM
· Snapshot 299
Like · Liked by · 0
can you paste the content of your local hosts file here?
· Snapshot 322
Like · Liked by · 0
Hello pkr_kancha,
Plz see below the contents of host file from local pc:
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
# rhino.acme.com # source server
# x.acme.com # x client host

# localhost name resolution is handled within DNS itself.
# localhost
# ::1 localhost

192.168.xxx:xxx Server1
· Snapshot 327
Like · Liked by · 3
Not sure if it's a typo but after third octet you've written colon instead of dot (192.168.xxx:xxx). Try replacing that colon with a dot. Also make sure there is at least one space between IP and the hostname. restart the machine(it helps)

· Snapshot 367
Like · Liked by · 0
pkr_kancha jyu,.
dherai dhanyabad, dherai. you found the issue :), the column. Meraj lai and tito_satya lai also dherai dhanyabad for your helping hands.

I wish you wonderful day/s ahead. I got moments to breath here..........
· Snapshot 581
Like · Liked by · 0
google bro , google is full of resources!! glad folks here are able to help!!
· Snapshot 708
Like · Liked by · 2
nepal12345678 bro,
Thanks for going over the issue. These superb people, and I am sure one of them is you are
as well because you provided an invaluable suggestion 'google bro'. Yes, I second to that. If anything I can say to our bros and sis working on IT or not, if you are looking for something goolge it, youtube it, chances are very high you will get what you are looking for. In some cases, though one may not be able to get from google for whatever reasons.
We should first google it.
In my case I did google, but was not able to resolve it. None responded, I kept working on my own. The best part of Meraj is that he gave lifeline to the thread with the invaluable advice, and pkr_kancha came with the detailed solution. I applied what was recommended and it worked like a magic whereever, I followed advice, but there I got one issue, that I tried to resolved it on my own but I was not able to see my own mistake there, pkr_kancha further offerred his help to look into the code itself, his expert eyes identified the a tiny column as the issue in place of a dot. And tito_satya was also proving me his supporting hands in the same time though he did not post here. I know all of these people were attending as if that was the high priority ticket on them,

Again, Kudo to you superbs! I got moments to breath.
· Snapshot 779
Like · Liked by · 0
yup. never give up. google, read, try, fail, again try and when u get success, you then become master. next time when u have any other issue,u do the same thing and you again become master. And then it becomes your troubleshooting habit and will give you confidence. Glad folks here investigated your issue like in an IT thread.

· Snapshot 1045
Like · Liked by · 0
this was informative, thanks
· Snapshot 1336
Like · Liked by · 0
Little late here but I suggest you to look into what DNS is and how it works. After you know what DNS is and how it works, you will find it easy to google because you will know what you are looking for. DNS is the backbone of internet so it is very very important concept if you are trying to get into IT.

Basically, in layman's term, DNS is just an infrastructure that is able to convert hostnames to IP address and vice versa. The infrastructure part is actually very interesting and complex and I wouldn't to justice trying to explain it to you here but. Google (TLD , and explore DNS RFC )

What i can explain you is how DNS is used. Internet address is numbers(IP address) and subnets(network segments). DNS give it a meaningful name so that you can write google.com vs an ip address.

In your case, you are running on VM. The VM software assigns a virtual network interface and all the guest hosts are assigned an IP address under that network interface by default. Since your host machine cannot talk to the guest machine because they are in different NETWORK by default. However most of the VM software also adds a bridge so that those two networks can talk to each other.
Now the DNS part, when you ping a hostname such as myguesthostname , Microsoft looks into its TCP / IP stack order which goes like this
-- check if it's querying for itself.
-- check on the local hostfile
-- send a query to its configured DNS server
-- And finally netbois as a backup.

Since the first logical place is to checks is hostfile , you edit the host file to map the hostname to the IP address as the simplest soution. all the host file says is hey if my computer asks for this hostname it actually this IP address.

You can also add an A record for that VM in your DNS server as a workaround but who has a local DNS server at home right ? (actually I do lol). Obviously, you can't add the A record in the public DNS(unless you own the domain) so the easiest solution for you is to add it to the local host file.


Last edited: 16-Oct-17 03:36 PM
· Snapshot 1437
Like · Liked by · 0
your information very useful, and helpful because you have tailored it to the needs of people like me.
like i said the gurus before gave me a lifeline, and your write ups provides additional inputs for further growth and strength. yes, people like you make a huge difference. While i will continue my research further, would you or someone please tell me what these commented lines mean in the host file?

what is '' which does not look like an ip address to me? and ' ::1'? why are both pointing to localhost? what is the implications if we uncomment them?

# localhost name resolution is handled within DNS itself.
# localhost
# ::1 localhost
· Snapshot 1503
Like · Liked by · 0 is indeed an IP address. Actually the first address in a class A network. Google network classes. There are three CLass A , B and C.

The first line is a IPv4 network and ::1 is a IPV6 network.
Google why there is IPV4 and IPV6 and what are the differences. There is a cool math and logic to it.
· Snapshot 1505
Like · Liked by · 0
and I forgot to mention both of these address are called Loopback address mainly used for testing traffic.
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 13 · Viewed 2031
· Posts 6 · Viewed 522
· Posts 1 · Viewed 54
· Posts 3 · Viewed 670
· Posts 1 · Viewed 347
· Posts 1 · Viewed 258
· Posts 1 · Viewed 174
· Posts 1 · Viewed 105
· Posts 4 · Viewed 1077
· Posts 4 · Viewed 153