If you need to allow other machines in your physical network reach your VM or if the VM needs Internet access, use bridged networking. Otherwise, stick to host-only networking.
Stop your VM and open the settings for it in the VirtualBox (OSE) Manager
Go to the Network tab
Select the network mode at your choice (bridged networking or host-only)
If you want to use bridged networking, you've to select the right network adapter at Name: ____________. For wired connections, you'd select something named like
eth0
. Wireless connections are usually namedwlan0
(the numbers may vary).Save the settings
Start the Ubuntu VM
When up, you can gather the IP address by running:
sudo ifconfig
The output should look similar to this:
eth0 Link encap:Ethernet HWaddr 08:00:27:f4:c3:7b inet addr:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fef4:c37b/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:20 errors:0 dropped:0 overruns:0 frame:0 TX packets:25 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3244 (3.2 KB) TX bytes:2512 (2.5 KB)lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
In the above output,
192.168.1.4
(on the second line) is the IP address that can be used in your Ubuntu host system to access your VM.Now open the hosts file in Ubuntu host machine:
sudo gedit /etc/hosts
(If you don't want to use
gedit
, replace the word with the name of your favorite editor. E.g.vim
,nano
.)Once the file is open, add this line, and save it:
192.168.1.4 my-dummy-site.com
Open any browser on your host machine and go to
my-dummy-site.com
to access your website, served right from VirtualBox.
( Special thanks to @iSeth for the help. Entirely based on this answer, bit is NOT the same. )