Re: how to get IP of guest operating system? Postby joseph1962smith » 1. Dec 2010, 05:15
From your question, I am assuming you are trying to get the IP address of the guest VM from the host system on which the guest VM is running.
The suggestion to use ipconfig (win) or ifconfig (*nix) will only give the IP address of the guest if the command is executed inside the guest VM.
VirtualBox does provide the ability to query guest VM properties using the "VBoxManage guestproperty" option. The "VBoxManage guestproperty" command can be executed against running and non-running guest VMs. Some properties (like the IP address) it appears will only be returned if the guest VM is running.
Here is an example of the "VBoxManage guestproperty enumerate <vmname>" from one of my guest VMs (this command was executed on the host):
$> VBoxManage guestproperty enumerate donaldOracle VM VirtualBox Command Line Management Interface Version 3.2.10(C) 2005-2010 Oracle CorporationAll rights reserved.Name: /VirtualBox/HostGuest/SysprepExec, value: , timestamp: 1290219934758787000, flags: TRANSIENT, RDONLYGUESTName: /VirtualBox/HostGuest/SysprepArgs, value: , timestamp: 1290219934758851000, flags: TRANSIENT, RDONLYGUESTName: /VirtualBox/GuestAdd/Vbgl/Video/SavedMode, value: 1024x768x32, timestamp: 1290219983629457000, flags: Name: /VirtualBox/GuestInfo/OS/Product, value: Linux, timestamp: 1290219981673702000, flags: ...
The IP related information is contained in the "Net" group of properties. To retrieve a specific value, use the "VBoxManage guestproperty get <vmname> <pattern> command.
Here is an example of the "VBoxManage guestproperty get <vmname> <pattern>" from one of my guest VMs (this command was executed on the host):
$> VBoxManage guestproperty get donald "/VirtualBox/GuestInfo/Net/0/V4/IP"Oracle VM VirtualBox Command Line Management Interface Version 3.2.10(C) 2005-2010 Oracle CorporationAll rights reserved.Value: 192.168.0.54$>
From my testing, it seems the guest properties are only available if the guest VM has the Guest Additions installed.