Connect to guest OS from Host OS

5,890

Solution 1

The IP address must be set in the guest system, not in the host. By your settings the interface replying to the 172.17.10.60 is your NIC visible in Windows.

First, go to the VirtualBox -> File -> Preferences -> Network and add/check the Host-only network settings if they are correct. By what you have written you should have there a network where address 172.17.10.60 is possible.

Then you can either use the DHCP to address the virtual machine or address it statically (turn DHCP off and configure the network directly in the guest).

In the guest, use ifconfig <interface> 172.17.10.60 netmask <host-only ntw. mask> or write the configuration into network scripts (something like /etc/sysconfig/network-scripts/ifcfg-<interface>; I do not know if this is correct on Debian-like systems but it should be something like that) to make it permanent.

Update from comment:

It is that the virtual network between virtual NIC in host and NIC in guest is created. So the NIC in host is different of that in guest. When using static addresses, you just configured the both NIC on the network to have the same IP which is obviously incorrect.

Solution 2

One of the easiest way to solve this is to change the adapter type from Virtual Box Host only Ethernet Adapter to bridged on VirtualBox, then you will have an IP of same range as your windows 7.

I always do this when testing some web applications and it works totally fine.

Solution 3

It should go steps by steps.

  1. Why type of network you are using, there are 3 type totally.

    • Host only <= you choose this one.
    • NAT
    • bridged
  2. The host-only network need a pair of IP, 1 at the guest OS, and 1 at the outside server. both of them should be private ip which does not interfere the outside network, and not used anywhere. for example 172.17.10.60 & 172.17.10.61

  3. ping test inside the guest OS and see if it can ping the assigned ip

  4. ping test inside the outside server and see if it can ping the assigned ip

  5. Turn off firewall of guest OS, it is pointless since it is a host-only network.

  6. ping test from guest OS to outside server and vice versa to confirm connectively

  7. unplugged all interface of the outside server and adjust firewall setting, anti-virus settings, if step 6 doesn't work.

Normally, the easiest setup would be bridged network, then you simply get 1 more ip from you lan and assigned to the guest OS would be fine. then you can treat the guest OS and the outside server as 2 separate machine.

Share:
5,890

Related videos on Youtube

AvinashK
Author by

AvinashK

Updated on September 18, 2022

Comments

  • AvinashK
    AvinashK over 1 year

    I have Ubuntu server 12.04 on VirtualBox inside Windows 7 OS. I set firewall inside Ubuntu to allow access to port 80. The Ubuntu server is running Apache server. I have chosen the Host-only Adapter mode inside VirtualBox and chosen the Virtual Box Host only Ethernet Adapter as the adapter type. Now I have set 172.17.10.60 as the IP address of Virtual Box Host only Ethernet Adapter by opening it in the Windows 7's Network and Sharing Center . But when I connect to http://172.17.10.60 from my Google Chrome inside Windows 7, it says Google Chrome could not connect to 172.17.10.60. So, then I run ifconfig on the VirtualBox Ubuntu Server. It gave me an IP address of 192.168.56.101. My questions are:-

    1. Why are the two IP adrresses different?
      and more importantly
    2. How can I connect to the Ubuntu server from Windows 7.

    If it helps, ping to 172.17.10.60 from Windows returns replies successfully. Thanks in advance.

  • AvinashK
    AvinashK over 10 years
    @Fiisch..I did that...I let 172.17.10.60 be the IP of Virtual Box Ethernet Adapter, switched off DHCP and configured ifconfig eth0 172.17.10.60 netmask 255.255.0.0 inside Ubuntu. Still the same result when I acess it from chrome
  • AvinashK
    AvinashK over 10 years
    @Fiisch...also Ping from Ubuntu to Windows 7's Ip says destination Host unreachable
  • Fiisch
    Fiisch over 10 years
    The way it is, you do not need to configure virtual adapter in Windows in any way (provided ou use DHCP). This can cause problems. You probably don't understand the architecture of host-only networking. It is that the virtual network between virtual NIC in host and NIC in guest is created. So the NIC in host is different of that in guest. When using static addresses, you just configured the both NIC on the network to have the same IP which is obviously incorrect.
  • Fiisch
    Fiisch over 10 years
    np :) I updated the original answer.