If I have a VM (using VirtualBox, for instance) running inside my main OS; how can I identify the virtual interface and IP address (of the VM) from within the original (host) OS?

I thought I could just use ifconfig, ip a, or similar; but no information related to the connected VM is displayed. Although it shows the main (host) OS has been assigned via wlan0.

However, if I run one of those commands from inside the VM, I can confirm that it's currently active @ via eth0.

  • 5
    If you use NAT mode for network emulation (default), it setups private network within VirtualBox which is not visible externally. You'll need bridged or host-only network configuration... – myaut Mar 12 '17 at 12:28
  • 1
    @myaut Ah. Okay, I thought it was bridged by default. But, even despite NAT; if the VM is receiving it's LAN connection, and it's route to the internet, from the main host; surely, the main host must have some kind of record of that link in the IP chain. Because it's accommodating what is effectively another system; forwarding packets back and forth, and that sort of thing. Right? – voices Mar 12 '17 at 14:32

Virtualbox includes a tool called VBoxManage. This tool can access information about the guest OS.

In this example (Windows 10, in a PowerShell window), I want to find the IP of my VM called DS201:

PS C:\Program Files\Oracle\VirtualBox> .\VBoxManage.exe guestproperty get DS201 "/VirtualBox/GuestInfo/Net/0/V4/IP"

(It works the same in Linux and Mac OS X as it does in Windows)

Documentation about the capabilities of VBoxManage can be found at https://www.virtualbox.org/manual/ch08.html.


FOR NAT MODE (per comments) from the manual subsection on NAT mode virtual networking

To your comment that the 'host must ... record ... the IP chain' it's VirtualBox, not the host as such, that does this:

The network frames sent out by the guest operating system are received by VirtualBox's NAT engine, which extracts the TCP/IP data and resends it using the host operating system. To an application on the host, or to another computer on the same network as the host, it looks like the data was sent by the VirtualBox application on the host, using an IP address belonging to the host. VirtualBox listens for replies to the packages sent, and repacks and resends them to the guest machine on its private network.

To your original Q, it is only VirtualBox that knows about the guest's simulated address:

The virtual machine receives its network address and configuration on the private network from a DHCP server integrated into VirtualBox. The IP address thus assigned to the virtual machine is usually on a completely different network than the host. As more than one card of a virtual machine can be set up to use NAT, the first card is connected to the private network, the second card to the network and so on. If you need to change the guest-assigned IP range for some reason, please refer to Section 9.11, “Fine-tuning the VirtualBox NAT engine”.


If Windows is your guest system, then with VirtualBox Guest Additions installed

  1. Click the Start button, type cmd.exe and hit Return to launch the Windows command line.

  2. Then paste and run:

    "c:\Program Files\Oracle\VirtualBox Guest Additions\VBoxControl.exe" guestproperty get "/VirtualBox/GuestInfo/Net/0/V4/IP"

  • Windows isn't the host OS - you can see that with the OP's comment, "I thought I could just use ifconfig, ip a, or similar" – roaima Dec 15 '17 at 10:28
  • Other people like me might find this question useful when their guest OS is Windows. – Lars Blumberg Dec 15 '17 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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