Access a web server located in a VirtualBox virtual machine from the Host operating system

10,560

Solution 1

The simplest way is to set the virtual machine to use bridged networking, it will get an IP address on your network; this IP address should then be accessible from your host machine.

From Chapter 6 of VirtualBox's manual:

With bridged networking, VirtualBox uses a device driver on your host system that filters data from your physical network adapter. This driver is therefore called a "net filter" driver. This allows VirtualBox to intercept data from the physical network and inject data into it, effectively creating a new network interface in software. When a guest is using such a new software interface, it looks to the host system as though the guest were physically connected to the interface using a network cable: the host can send data to the guest through that interface and receive data from it. This means that you can set up routing or bridging between the guest and the rest of your network.

It is also possible to use the NAT networking mode, but it will require tinkering with port forwards (not worth the trouble, in my opinion).

Solution 2

The way I would do this (especially if you are on a home network) is to set the networking adapter to a bridged adapter. This way the guest VM is assigned it's own IP, and is accessible from any machine on the local network. It's the most convenient, and the won't have to mess around with port forwarding (which can get complicated).

A good reference for all the VBox networking modes is: http://www.virtualbox.org/manual/ch06.html

Share:
10,560

Related videos on Youtube

Mangano
Author by

Mangano

Updated on September 18, 2022

Comments

  • Mangano
    Mangano over 1 year

    I have a Mac OS X installation and a Ubuntu Virtual Box inside them. I use the Debian Virtual Box as a development machine for several rails and php web projects, but I want to access them from the Mac OS so I can tested on Safari, it is possible do this? how?

    Thanks in advance

  • Mangano
    Mangano almost 12 years
    I did it, but I don't know what is the IP address that virtual machine have, how can I know that?
  • Renan
    Renan almost 12 years
    From what you say in your question, the virtual machine is Linux. Thus, open a terminal in the virtual machine and type ifconfig.
  • philx_x
    philx_x over 9 years
    woks like a charm! exactly what i was looking for .. i think this answer should get marked as the right one