17

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.

enter image description here

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

2 Answers 2

13

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.

3
  • thanks i sorted it out by making it as Adapter and restarted the VM Nov 27, 2012 at 14:27
  • I searched the internet for hours, finally found this answer. Sometimes RTFM saves your time actually. Thank you!
    – C.W.
    Oct 9, 2018 at 2:45
  • Pertaining to the host-only networking solution, can someone explain in more detail how this works, and how to route it through?
    – scoots
    Nov 12, 2018 at 23:42
0

You should either expose IP address of VM to external network and NOT make it DHCP, either set up packet routing on PC2 so it will work as proxy (which i've no idea how will you do it on Windows, on Linux it is way easier).

As an option you can setup web-server on PC2 and make it proxying to VM, but again in this case u better off with static IP for VM and not DHCP.

Third option would be combine all of machines into VPN where PC2 will be a router/server. But that is too complex on Windows to set up.

1
  • well i make it static and set it as a bridge adapter same happens where i can get a network range ip on VM bt cannot ping from outside Nov 26, 2012 at 11:12

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.