Use VirtualBox to access site on host from guest?

4

2

I'm running VirtualBox on a Mac (host), the VM i'm using is windows 7 (guest). VirtualBox is setup to use the NAT network adapter, and I'm able to get to the internet just fine (google, msn, everything) however I'm hosting a site on the Mac(host) and I cannot access it from the VM.

The guest is assigned the IP 10.0.2.10 and my host's IP is 10.0.2.100, I think the issue might be that these are separate networks, but I don't know. I just want to test the site in IE (I don't have a separate/remote server to host it on)

JKirchartz

Posted 2012-04-27T20:23:56.657

Reputation: 300

2You need to change it to a Bridged network on the VM, or else bridge your virtual adapter and your normal Mac one, whether it's Wi-Fi or Ethernet. – None – 2012-04-27T20:32:01.993

For future reference: http://www.virtualbox.org/manual/ch06.html#networkingmodes

– Der Hochstapler – 2012-04-27T20:34:46.933

Answers

6

You should really consider switching from NAT to bridged mode. This way both "systems" will be on the same network. When you run with NAT it subnets the network and your VM effectively exists in another network. In order to make it work with NAT you will need to configure (through configuration files, not GUI options) the NAT routing to open connections/ports between the networks, and also setup routing tables.

If you set bridged mode, the VM requests the IP from the same router that your host does, instead of from the VM system on the host. In turn it will be as easy as just going to the IP of your host.

BloodyIron

Posted 2012-04-27T20:23:56.657

Reputation: 1 981

I thought I tried this before, but it works now... – JKirchartz – 2012-04-27T20:36:27.637

Thanks for this. One comment for any other readers: to access a website at localhost on the host (for example Rails development sites run at localhost:3000), enter in the host's IP plus port: eg. http://10.0.0.5:3000/. If this doesn't work, ensure the http:// is there (some browsers are picker than others) and also check firewall settings on the host.

– Topher Hunt – 2014-05-19T15:17:37.663

2

By default the network adapter is "NAT" mode. You need to put your network adapter in bridge mode. Here are the steps.

1> On the virtual box select the vm you want " Eg win7" 2> Go to settings -> Network -> Adapater1

 Change that from NAT -> Bridged Adapter 

3> Reboot your guest VM

Hope that should resolve your issue.

Chakri

Posted 2012-04-27T20:23:56.657

Reputation: 161