To linux and devops gurus - Sajha Mobile
SAJHA MOBILE
To linux and devops gurus
Posts 16 · Viewed 13658 · Likes 7 · Go to Last Post
Ghiraunla
· 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
meraj
· 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
pkr_kancha
· 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.
Ghiraunla
· 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
pkr_kancha
· Snapshot 299
Like · Liked by · 0
can you paste the content of your local hosts file here?
Ghiraunla
· 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:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

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

192.168.xxx:xxx Server1
pkr_kancha
· 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)


Ghiraunla
· 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..........
nepal12345678
· Snapshot 581
Like · Liked by · 0
google bro , google is full of resources!! glad folks here are able to help!!
Ghiraunla
· 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.
nepal12345678
· 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.

Mr33Sajha
· Snapshot 1045
Like · Liked by · 0
this was informative, thanks
fdpower
· 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
Ghiraunla
· Snapshot 1437
Like · Liked by · 0
fdpower,
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 '127.0.0.1' 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.
# 127.0.0.1 localhost
# ::1 localhost
bahadur1
· Snapshot 1503
Like · Liked by · 0
127.0.0.1 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 127.0.0.1 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.
bahadur1
· 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 11 · Viewed 2085 · Likes 6
· Posts 18 · Viewed 1627 · Likes 1
· Posts 1 · Viewed 117
· Posts 1 · Viewed 112
· Posts 1 · Viewed 213
· Posts 1 · Viewed 179
· Posts 2 · Viewed 497
· Posts 6 · Viewed 878
· Posts 1 · Viewed 212
· Posts 1 · Viewed 207



Your Banner Here
Travel Partners
Travel House Nepal