1

I have installed VirtualBox and a guest machine with Ubuntu.

From my host Ubuntu, I can browse to 192.168.56.10 and see webpages inside my guest Ubuntu server (and I can ssh user@192.168.56.10 into my guest machine, too)

Now my question is:

How to remotely access this website which resides inside my guest machine?

guest static ip: 192.168.56.10

host static Internet ip: 11.11.11.11 (I do have static Internet IP, but this only as example)

I want to be able to browse to http://11.11.11.11 from any computer and visit that page inside my virtual machine

  • In this example, the virtualbox version included in Ubuntu, may be the lest optimal option available. Normally kvm and lxc are better off for this kind of task. – Braiam May 5 '16 at 12:40
2

In your router forward port 80 and 443 to 192.168.56.10

Then when an external request hits port 80 or 443 http https it will be routed to the VM guest machine at 192.168.56.10

This may only work if your default gateway is 192.168.56.1 or you may have to change the static address on the guest so matches the gateway .. for instance if your default gateway was 192.168.1.1 then you would need a static IP in the guest as 192.168.1.xxx .. for the easiest setup

Just as an added note that I was just reminded of .. this setup I use myself but I use a bridged connection in VirtualBox not the default NAT connection and now that I look at it, the above IP is most likely a NAT connection in Vbox

1

You should use port forwarding capabilities of virtualbox. You'll find this settings on the adapter properties of your VM. Forwarding 80 and 443 should be enough.

See virtualbox manual here for more details: https://www.virtualbox.org/manual/ch06.html#natforward

I assumed that your host has a static public IP. If it's not the case, as said john, you will need to forward those ports on your router too.

  • he would still have to open the ports in his router to his host machine then – John Orion May 5 '16 at 5:39
  • @JohnOrion was editing my answer while you were commenting :) If the OP is behind a NAT router then yes. – daniel May 5 '16 at 5:55
  • yeah I just wanted to go the easiest route for him .. I have a VM that runs a radio station program and it needs a port available from the internet for requests. Since I have my VM showing on my network just as if it was a physical box .. it was simple for me to go into the router and forward that port to my VM... though the VM is set up with a bridged connection .. I always had trouble with NAT and VMs – John Orion May 5 '16 at 6:07
0

Actually I did not need to do anything.

From my configurations in the my question above, I just needed to know the IP address of my virtual machine, then from any computer connected to my physical network I can just type that address the web browser.

I used ip addr show, it spit number of IPs, one is the static ip with my host ip. The other one from the bridged adapter interface (which was the one used by other PCs in my network).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.