Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Can I determine the IP of a virtual machine using VMware Fusion without actually entering the operating system running on the virtual machine? I'm looking for a menu option, command line, or otherwise that I can issue against the virtual image with the VMware Fusion Software itself.

Thanks - Adron

share|improve this question
    
If you know the MAC address of the virtual machine NIC you could always try to leverage your host machine's ARP cache, or reverse ARP. –  ta.speot.is Dec 31 '11 at 0:59

6 Answers 6

up vote 1 down vote accepted

Short Answer: No

Long Answer: No but maybe

An IP address is purely the responsibility of an OS. Therefore, the virtual framework that holds the OS has no idea about the TCP/IP stack within unless there are symbiotic additions to the framework such as Hyper-V and VMware's additional guest tools (thanks to todda.speot.is in the comments below). It's not much different than wanting to browse the files on a VM without starting it up first.

Technically, if the VM relies on DHCP, you could search your DHCP server (likely your LAN's router) for the last lease that was handed out to the MAC address of the virtual NIC to get a good idea of what the IP would probably be the next time it launches. That's assuming that same IP wasn't handed out to another device in between when you looked at the lease history and when the VM started up.

share|improve this answer
    
Argh. I was hoping that VMware had some hooks into the OS that would provide that. :( I have no access to the corporate DHCP, thus have no idea since I don't have access to the actual OS either. –  Adron Dec 31 '11 at 0:47
    
A hypervisor can hook in and get the IP address, Hyper V does it with its Guest Additions. And it seems some flavours of VMware will tell you, too kb.vmware.com/Platform/Publishing/images/1006098.JPG - but as WesleyDavid said, it's not really the hypervisor's responsibility to worry about this. –  ta.speot.is Dec 31 '11 at 0:58

Here's a tip in case it helps anyone. Install avahi-daemon on the VM. This allows you to connect via hostname vmname.local, where vmname is the name of your virtual machine. In my case, the VM's name is baremetal and on the host I can run:

ssh baremetal.local

No need to know the VM's IP. :)

share|improve this answer
    
Nice idea but what about VMs that run operating systems where avahi-daemon is not available? Windows for instance comes to mind... :-) –  user465139 Sep 1 at 9:18

It is possible -- at least, in the common case, where NAT-style network is configured for the guest. Because VMWare is providing the NAT-ing, it ought to be able to tell us, what addresses it is currently NAT-ing for. Something like vmrun list should be outputting this information. That it does not is a flaw...

But, in any case, here is how one can find out anyway. First, run ifconfig on your Mac (perhaps, ipconfig would do the same on Windows, but I haven't tested it). This will list all network interfaces on the machine -- both physical and virtual. Look for the vmnet-ones. On my Mac this produces:

% ifconfig | grep -A2 ^vmnet
vmnet1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:50:56:c0:00:01 
inet 192.168.82.1 netmask 0xffffff00 broadcast 192.168.82.255
vmnet8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:50:56:c0:00:08 
inet 192.168.123.1 netmask 0xffffff00 broadcast 192.168.123.255

So, my guest's IP is on either one of these two VM private networks: either 192.168.82.0/24 or 192.168.123.0/24. On your host there may be just one, lucky you, or more than two -- we need to check them all. Here is a very simple tcsh-script, entered directly on command-line, that did it for me. It attempts to ping each address in all of the class-C private networks managed by vmnet and ends, when a ping succeeds. The -W 500 option tells ping to wait only half a second for a response (could, probably, use even less), and the -c 1 tells it to send exactly one packet:

% set i=2
% while ( $i < 255 )
while? ping -W 500 -c 1 192.168.82.$i && break
while? ping -W 500 -c 1 192.168.123.$i && break
while? @ i++
while? end

The above little script ran for some time listing all the unsuccessful attempts to reach the non-existent addresses:

PING 192.168.82.2 (192.168.82.2): 56 data bytes

--- 192.168.82.2 ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss
PING 192.168.123.2 (192.168.123.2): 56 data bytes
...

Until it finally succeeded and finished:

64 bytes from 192.168.123.130: icmp_seq=0 ttl=64 time=0.307 ms

--- 192.168.123.130 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss

Voilà, I was able to ssh into my guest:

% ssh 192.168.123.130
Password:

Now, I only had a single guest running -- so the first IP-address to respond to a ping was the right one. If you run multiple guests at once, you may need to use the same or similar ping command to build a list of all such valid private IP-addresses and then try them all until you get into the correct guest...

(And, maybe, .130 is a good guess for NAT-based addresses anyway. But I can't say for sure.)

share|improve this answer

My solution to this was:

Once you have VMware tools installed, configure sharing, so that you can access a folder (any folder) from CentOS. Then, modify /etc/sysconfig/network-scripts/ifup-post to append your current date & ip address to a file in this shared folder.

How to do this:

Modify: /etc/sysconfig/network-scripts/ifup-post

add this before the last line of ifup-post ("exit 0"):

date >> /path/to/shared/folder/guest_ip.log
ifconfig >> /path/to/shared/folder/guest_ip.log

This will append your guest_ip.log with the date and return value of ifconfig each time the network comes up.

In my case, I decided to grep for a prefix of 192 on my ip address, since i know that between my home and work, it is always 192. This can be done by adjusting the above as follows:

date >> /path/to/shared/folder/guest_ip.log
ifconfig | grep 192 >> /path/to/shared/folder/guest_ip.log
share|improve this answer
    
"so that you can access a folder (any folder) from CentOS.". What about those people who 1) use other Linux distributions, 2) use UNIX operating systems other than Linux, 3) use non-Unix operating systems such as Windows, ... in their VMs? :-) –  user465139 Sep 1 at 9:20

Run in VM console ipconfig (if VM is Windows) or ifconfig (if VM is Linux).

IP of eth0 is the IP address that you are looking for.

share|improve this answer
    
The original question was "without actually entering the operating system running on the virtual machine?" This might have escaped your attention. –  user465139 Sep 1 at 9:22

As Mikhail T. said, "Because VMWare is providing the NAT-ing, it ought to be able to tell us, what addresses it is currently NAT-ing for." Indeed it does:

In my VMware Fusion 6 installation, the vmnet-dhcpd daemon writes its leases to the files /var/db/vmware/vmnet-dhcpd-vmnetX.leases, where "X" is 1 and 8. Empirically :-) I established that it is vmnet8 that I should look for. Here is an excerpt from the lease file /var/db/vmware/vmnet-dhcpd-vmnet8.leases:

lease 192.168.177.129 {
    starts 1 2014/02/17 09:34:19;
    ends 1 2014/02/17 09:36:56;
    hardware ethernet 00:0c:29:2b:2b:10;
    client-hostname "ubuntu";
}

The client-hostname is the name of the VM and the number after the word lease is its IP. You can parse these entries or just simply look at the most recent ones. Make sure the lease you are looking at is still valid.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.