How to find the IP address of VMware virtual machine

Last updated on December 10, 2012 by Dan Nanni

When you run a virtual machine (VM) created by VMware Player or VMware Server, there can be circumstances where you don't have console access to the VM. For example, you could be running your VM without VMware Player GUI, or you may have trouble opening a remote console from VMware Server. If you don't have access to VM console, you will need to remotely ssh to the VM by using its IP address. But how do you find out its IP address in the first place?

If you want to find the IP address of VMware VM, here is what you can do. There are two types of networking used for VMware VMs: NAT networking and bridged networking. Depending on whch type of networking you are using, you can try different approaches. Note that if you are interested in finding out the IP address of a VM created with KVM hypervisor, refer to this tutorial instead.

NAT Networking

If your VMware VM is using NAT networking, VMware's internal DHCP server (dhcpd) from which the VM obtained its IP address is running on the VMware host. You can find DHCP lease info of dhcpd in the following location of the VMware host.

$ cat /etc/vmware/vmnet8/dhcpd/dhcpd.leases
lease 172.16.173.132 {
        starts 5 2012/08/31 19:46:58;
        ends 5 2012/08/31 20:16:58;
        hardware ethernet 00:0c:29:72:77:c6;
        client-hostname "my-host";
}
....

As you can see above, the DHCP lease file contains a list of IP addresses that are leased out to VMs, and detailed lease info (including hostname). From this information, you can infer the IP address of your VM.

Bridged Networking

If your VMware VM is using bridged networking, the VM gets its IP address from an external DHCP server running somewhere outside your VMware host. In this case, you can snoop on DHCP offer(s) sent to the VM from outside, to infer the IP address assigned to the VM. To do that, you first identify the MAC address of the VM from its .vmx file.

$ cat my_host.vmx
....
ethernet0.generatedAddress = "00:0c:29:bd:81:01"

As shown in the sample .vmx snippet above, the MAC address of a given VM is found in ethernetX.generatedAddress field.

Next, you can use a tool called dhcpdump to monitor DHCP traffic from the command line. dhcpdump captures DHCP packets and shows DHCP activities in human-readable format. It also allows one to filter DHCP traffic based on receiving client's MAC address. Using this feature, you can capture DHCP OFFER messages being sent to the VM, which will contain the VM's potential IP addresses.

Go ahead and run dhcpdump with MAC address filtering on VMware host as follows.

$ sudo dhcpdump -i eth0 -h ^00:0c:29:bd:81:01
  TIME: 2012-11-19 21:53:47.373
    IP: 1.2.3.1 (0:e0:b1:cb:7:30) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
    OP: 2 (BOOTPREPLY)
HTYPE: 1 (Ethernet) HLEN: 6 HOPS: 0 XID: a06c6363 SECS: 0 FLAGS: 0 CIADDR: 0.0.0.0 YIADDR: 1.2.3.100 SIADDR: 0.0.0.0 GIADDR: 1.2.3.1 CHADDR: 00:0c:29:bd:81:01:00:00:00:00:00:00:00:00:00:00 SNAME: . ....

In the DHCP OFFER message as displayed by dhcpdump, the YIADDR field shows the IP address (e.g., 1.2.3.100) offered to the VM.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean