VMware {code} Community
bvivek
Contributor
Contributor

Is there any way to fetch the FQDN of a VM?

I could not find any hint in vSphere API reference where I can  find FQDN of a VM. I believe that this is not a general property which should be known to vmware tools on VM or vcenter/esx server. So there cannot be a way to find FQDN of a VM using vSphere API. Am I right?

Thanks,

Vivek.

0 Kudos
11 Replies
bulletprooffool
Champion
Champion

Powercli can extract this I think - like so:

$myguest = get-vm $vmname | get-view

write-host $myguest.Guest.Hostname

So I assume you can do it from the SDK - just not sure how - sorry.

One day I will virtualise myself . . .
0 Kudos
lamw
Community Manager
Community Manager

FQDN of a guestOS is only available if VMware Tools is installed in a VM, other than that, you'll only be able to retrieve the VM shell name which is the display name you've given it when creating the VM.

You can get the guest information by looking at the guestInfo property of a VM IF VMware Tools is installed, else it will be null - http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.GuestInfo.html

0 Kudos
phallur
Contributor
Contributor

Did you mean to say that the "hostName" property of the GuestInfo data type is the FQDN of the VM?

Thanks,

Parash

0 Kudos
Virtualinfra
Commander
Commander

1. Make sure VMware tools in installed on all the guest operating system.

2. Click on inventory and datacenter or cluster.

3. click on virtual machine screen in right side.

4. right click on the tab choose DNS name\

5. go files and export list as a excel or csv and thats all you got all the guest operating system DNS name.. missed once check if that is registered to DNS server or has set up a proper loookup..

Regards

Dharshan Samugan

Thanks & Regards Dharshan S VCP 4.0,VTSP 5.0, VCP 5.0
0 Kudos
phallur
Contributor
Contributor

I have few more questions -

In the Virtual Machine's summary tab, the DNS name will be populated. Is this name the value populated at the "hostName" property of the GuestInfo?

Also, what name will be populated under DNS Name if I have multiple IPs configured for a VM and each of these IPs are assigned a FQDN?

0 Kudos
Virtualinfra
Commander
Commander

1. Name is what you give to the server when you created it in the inventory- just like a label, it might differ from server name which you give in operating system,

2. DNS name is the name to which the IP is registered to the DNS server.

3. you can have multiple IP registered to DNS, but you will have only one IP configured primary and that IP DNS will be populated in DNS tab in VM summary

Thanks & Regards Dharshan S VCP 4.0,VTSP 5.0, VCP 5.0
0 Kudos
phallur
Contributor
Contributor

Thanks Dharshan for the response. That helps.

I'm trying to find the answer for the one more question - How to you identify which is the primary IP of the VM. I tried looking at the vmware documentation on networking, I have not yet found the answer. Could you please let me know if you have any pointers.

0 Kudos
Virtualinfra
Commander
Commander

The IP that is configured in the screen shot is primary IP.

Thanks & Regards Dharshan S VCP 4.0,VTSP 5.0, VCP 5.0
0 Kudos
phallur
Contributor
Contributor

So If I have two vNics in a VM and both are configured to obtain the IP address automatically. Which one should I consider the primary IP?

0 Kudos
lamw
Community Manager
Community Manager

If you look at your VM configuration through the vSphere Client, you will notice that if you more than one ethernet adapter, they'll be label "Network Adapter 1, 2, etc.". Assuming you're using the first ethernet device, you can key off of that value by using the deviceName property as you iterate through the hardware devices - http://vijava.sourceforge.net/vSphereAPIDoc/ver5/ReferenceGuide/vim.vm.device.VirtualDevice.DeviceBa...

0 Kudos
Virtualinfra
Commander
Commander

If you have 2 Nic both the NICS IP will be displayed in the virtual machine summary and both the DNS name will be populated in the DNS tab of virtual machine summary. see if you have test environment test that out.. its as simple as that..

Thanks & Regards Dharshan S VCP 4.0,VTSP 5.0, VCP 5.0
0 Kudos