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.

I'd essentially like to access my host computer from the guest in VirtualBox. Is there an IP address given for my host which I can use from the guest? Are there extra steps required to set this up? I'd like to access my host's Apache, FTP, and SSH services.

share|improve this question
1  
Difficult to solve without any hint which network confiuguration your guest actually has. Some do not allow access to host. Try the default gateway address of the guest. –  Turbo J Jul 15 '11 at 1:12
1  
Turns out I can reach it through my default gateway at 10.0.2.2. –  Naftuli Tzvi Kay Jul 15 '11 at 1:42
add comment

5 Answers

up vote 59 down vote accepted

In the default setup, you should be able to reach your host through your default gateway, in my case 10.0.2.2. You can easily determine this IP address in Windows via ipconfig. It should dump out something like this:

Windows IP Configuration


Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 10.0.2.15
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 10.0.2.2

In Unix/Linux based guests, use the netstat -rn command. It should dump out something like this:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 wlan0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 wlan0

In case one, my default gateway is 10.0.2.2, in the second case, its 192.168.1.1.

share|improve this answer
1  
Thanks! I have been struggling with this for weeks. –  Rob W Feb 18 '12 at 18:38
add comment

Another way to do this is to use a "Host" type of virtual network. That gives you an interface in the guest OS with an address on a local subnet different from the "outer world" subnet(s) that your host machine is on. To make this work, you have to make sure of a few things:

  • Your VM has a "host only" adapter configured;
  • Your host services need to be listening on all local adapters, or at least the ones you want to be able to contact;
  • Your host will get its own virtual adapter, and you'll want to figure out its IP address and add it to the "hosts" file in your guest OS (however that works for the guest OS; on Windows XP, it's just the "hosts" file buried in C:/WINDOWS/system32/drivers/etc). Give it a name you want to use for the host's host name.

Once you've done this, you should be able to "see" the host from the VM via the name you coded into the host file.

For example, on my Ubuntu 11.04 host, I get a "vboxnet0" virtual interface on 192.168.56.1. The adapters in the machines come up with something like 192.168.56.101. I don't need to go in to my VMs, but I presume that'd be possible via a symmetric change to the host's host file. I add

192.168.56.1 mymachine

to the guest OS host files, and they can (for example) see my host machine's web server at

http://mymachine/whatever

You can of course have both bridged and host-only adapters set up.

share|improve this answer
add comment

Accessing the web server of host computer from the guest is easy. This can be done easily using two methods. First do the following

  • Go to Devices and select Network Adapters...
  • In the adapter settings, check for Attached to.
  • If the value is NAT, do following

  • The default gateway when you setup Virtual box is generally 10.0.2.2 as default value. If you have not changed anything this will work. But if you have changed it and the guest machine you are running is windows run following command and find the default gateway

    ipconfig /all

    If you are on Linux, Unix or Mac OS, run the following command to get it

    netstat -rn | grep 'default' | awk '{print $2}'

  • Go to the web browser and type in this default gateway and press enter. The web server can be accessed.

  • If the value is Bridged Adapter, do following
    • find the ip address of host and guest
      • if you are on windows, run ipconfig and get the ip address
      • if you are on Linux, Unix, or Mac OS, run ifconfig | grep 'inet' and get ip address
      • the ip address is like 192.168.1.1
    • if you want to access host, run browser in guest and enter ip address of host
    • if you want to access guest, run browser in host and enter ip address of guest
share|improve this answer
add comment

You can create shared folders in VirtualBox. This will automatically create a 'network share' within Virtual Box to access folders in your Host OS.

Here's a decent step by step in a Windows XP guest OS:

http://www.giannistsakiris.com/index.php/2007/09/28/virtualbox-access-shared-folders-from-windows-xp-guest-os/

share|improve this answer
    
So I can access my host at /vboxsvr/ShareName ? –  Naftuli Tzvi Kay Jul 14 '11 at 23:10
    
Yes, you would set a folder like C:\STUFF to be shared with VirtualBox. Within VirtualBox Guest OS, you can go to that vboxserver and access the shared folders. –  kobaltz Jul 14 '11 at 23:12
    
I actually don't want the shared folder. I want an IP address for my host machine. When I get it, I'd like to use it to use services on my host machine, ie: echo "GET /\r\n\r\n" | nc 192.168.100.100 80 (send a HTTP GET request to my host machine from the guest.) –  Naftuli Tzvi Kay Jul 14 '11 at 23:15
1  
In that case, you may need to set your Guest OS network adapter to a Bridge. This will pull an IP address from your DHCP or Router. You would then be able to natively access your host machine through IP address instead of the VBox Shared Folder. –  kobaltz Jul 14 '11 at 23:18
add comment

Here is another solution to this issue by using an additional network interface and setting traffic destined for the host to route over an additional interface.

share|improve this answer
1  
Welcome to Super User! It would be nice to include the essential parts of the answer here, and provide the link only for future reference. –  slhck Mar 28 '12 at 15:38
add comment

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.