Ubuntu – How to remotely access website in the virtual machine

networkingvirtualboxvirtualization

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

Best Answer

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