Network access to VirtualBox VM from Network PCs
Well, I have setup a VM in Virtual Box in a PC (label as PC2), and I have hosted a web service in the VM (IIS).
PC2 - Windows Server 2003 VM - Windows 7 x86
Now I want to access the web services from another PC (label as PC1) within a network that PC1 has connected. The following diagram will be helpful to get a clear idea.
So the LAN is 192.168.5.0. But virtual network ports IP is 192.168.56.1 by default. In the VM, its IP from DHCP by default. (ipconfig gives you IP address like 10.0.0.2.15, subnet mask 255.255.255.0 and gateway as 10.0.2.2).
At this point, I can ping PC1 (192.168.5.31) from VM (10.0.2.15), but I cannot ping 10.0.2.15 from PC 1. Even if I make VM and PC2 virtual ports IPs to some static range, from VM, I can't ping any IP.
How to solve this situation? Thanks in advance
Solution 1:
If you just used the default Network settings in your VM, it will be NAT with DHCP. That means you get a LAN IP from your VirtualBox DHCP Server and you can't really access the machine from the outside.
Check out the VirtualBox Manual on Networking: https://www.virtualbox.org/manual/ch06.html#networkingmodes
I guess bridged neworking should be best. You should configure a static IP address.
EDIT: Concerning the edit removing "host-only networking": It's true that you can't see the VM from outside. But you get virtual interfaces (vboxnetX) on your host machine. So if you route it through, it should work. The setup is more complicated, but the VM is less exposed.