Ask Your Question

How to get the IP address of Host Machine from VM launched on it?

asked 2017-05-15 00:55:10 -0500

Mohan gravatar image

I have VMs running on my Openstack Cloud setup. I wan't to get the IP address of host machine from VM for some application purpose. How can I determine it.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-05-15 03:58:35 -0500

updated 2017-05-15 03:59:21 -0500

Not out of the box, as far as I can tell. In my opinion, this is by design: Non-admin users are not exposed to the cloud implementation. In particular, as a normal user, you can't see the host on which your instance is running, and you can't perform tasks like migrating the instance.

I see two ways:

  1. As admin, use openstack server show to get the node name and add it to the instance as metadata or send it to the instance in another way.
  2. If the instance has network access to the cloud's API, the instance can do a openstack server show itself. Its UUID is in the metadata (curl

Interestingly, when looking through the metadata to answer this question, I found that informs us about the VM's network connection to its host:

$ curl
{"services": [], "networks": [{"network_id": "a169dd81-b4ab-48c1-812b-d118e7bf4ef2", "link": "tapace05a8f-27",    "type": "ipv4_dhcp", "id": "network0"}], "links": [{"ethernet_mac_address": "fa:16:3e:64:da:64", "mtu": 1450, "type": "bridge", "id": "tapace05a8f-27", "vif_id": "ace05a8f-27d1-4a62-91c7-a3f6aac51839"}]}

In my opinion this violates the principle that users should not see implementation details.

edit flag offensive delete link more


Thank You @Bausch for the reply.

We are aware of command openstack server show but in particular I'm asking how to know the host name sitting inside VM?

Mohan gravatar imageMohan ( 2017-05-15 04:37:06 -0500 )edit Is this the IP of the cloud or the VM? and how can the instance have network access to the cloud's API ?

ShubhamMeshram gravatar imageShubhamMeshram ( 2017-05-15 05:26:35 -0500 )edit

and assume I do what ever you said above about the curl command and if thats the output then, where in that output am I getting to know the Host details?

ShubhamMeshram gravatar imageShubhamMeshram ( 2017-05-15 05:27:53 -0500 )edit

@ShubhamMeshram: is the IP address of the metadata service. It does not contain VM host info.

Instances often have access to the external network, and the API could be accessible from the external network.

Bernd Bausch gravatar imageBernd Bausch ( 2017-05-15 08:53:08 -0500 )edit

@Mohan: As I said, this is not possible out of the box, for the reason given. I gave you two workarounds; the second one works entirely inside the VM if the VM can access the cloud's API.

Bernd Bausch gravatar imageBernd Bausch ( 2017-05-15 08:54:03 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools


Asked: 2017-05-15 00:55:10 -0500

Seen: 3,216 times

Last updated: May 15 '17