Create Server on VirtualBox visible from outside, host is not behind router

4

2

I am trying to create a web server on a Virtual Machine. I would be happy even if I could access it with something like http://xxx.xxx.xxx.xxx:[port_no] Everything is installed but the step of facing the outside world presents some problems for me, mainly because I am not behind a router. Here are some details:

Host OS: Ubuntu 12.04 The Host is connected to the world through a static IP (Ethernet), there is no router (it is a PC on a University campus and there is no DHCP). There is no firewall from the University administrators.

Guest VM: Ubuntu 14.04 (no windows environment) on VirtualBox.
When using NAT I can connect to the Internet, but if I understand correctly, a Bridged adapter would mean I need either a new static IP or a to be behind a router. When I enable the Bridged Adapter I get an IP 10.0.2.15, I am guessing on an adhocLAN, and ofcourse it does not work.

Is there any solution for my problem?

papnikol

Posted 2015-05-21T16:43:08.667

Reputation: 1 269

Answers

5

Sure, this is definitely possible. You just need to do some port-forwarding settings from your Virtualbox interface.

Go to Settings -> Network -> Port Forwarding. Then, add a new rule. In the host port, add some port which you wish to use, say 1212. In the guest port, add port 80 which is the default for apache.

Start your virtual machine and that's it. Your web-server can now be reached from your host machine as: http://localhost:1212, and from the external world as <Public-IP>:1212.

Screenshot: enter image description here

PS: You don't need to use bridged connection or anything like that. Just keep it at NAT.

shivams

Posted 2015-05-21T16:43:08.667

Reputation: 1 269

wow, it worked, so simple and yet so elegant. Thank you. – papnikol – 2015-05-21T17:38:38.887

Happy to help :) – shivams – 2015-05-21T17:41:38.860