1

I have a virtualbox setup with both the host and VM OS as Windows 7. The host and the VM are both connected to the network but have different network IPs.

ipconfig on host (including only those adapters that show as connected):

Wireless LAN adapter Wireless Network Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::5019:de7c:51c0:f4f3%11
   IPv4 Address. . . . . . . . . . . : 192.168.43.121
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.43.1

Ethernet adapter VirtualBox Host-Only Network:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::cab:cd07:1f1b:79c3%17
   IPv4 Address. . . . . . . . . . . : 192.168.56.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

On the VM:

Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::b941:4a97:86ff:b28c%11
   IPv4 Address. . . . . . . . . . . : 10.0.2.15
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 10.0.2.2

I would have expected a VirtualBox NAT adapter on the host but there isn't one and that the network on both to be the same but they are completely different. How can I connect to the Virtual Machine from the host?

Edit: It seems there was a gap in my understanding, NAT adapter cannot be accessed from the host to guest, it is internal to virtualbox(however I am not sure of this). I added a host only adapter and now I can access the guest from the host but not from the guest to host. How do I make that work?

2
  • Have you installed Guest Additions inside the virtual machine?
    – harrymc
    Nov 14, 2017 at 20:02
  • Hello. Windows virtual networking can be quite a hell. Host-only network should work. If I get your 14h ago comment correctly your problem is the following: Your host can ping your guest, but your guest cant ping your host. If this is the case maybe this is just a Windows Firewall issue on the virtual network card. Try disabling both firewalls and report back. If this doesnt work, you should make a NATed network and disable routing in your windows host if you dont want packets in/out that network.
    – DGoiko
    Nov 15, 2017 at 2:09

2 Answers 2

0

Update: You have configured the VMs network interface on 10.0.2.15 but your virtual network interface of the ohst in on 192.168.56.1. They are not on the same network, thus can talk. See updated instruction under 1. for instructions.


Seems like you have run into the virtual networking jungle. It can be quite confusing. So let me make things a bit clearer for you:

  1. Host Only Network: for communication between virtual machines and your host. A new virtual network interface is created for your host, which has a its own addresse. Which means unless you make a service listen on the address it will not be reachable. Add a new host only network under Preferences>Networks>Host Only Networks. Pay attention to the following: the address you enter is the address of your host in this network not the network address (It will accept eg. 172.16.0.0 but this will break things). Configure the DHCP settings correctly, they are not automatically updated if you change the address of your virtual network adapter. It will happiely hand out 192.168.56.x configurations to all even if you have a different address configured. If you configure the VMs in this network manually, make sure they are on the same network as the virtual network interface of your host.

  2. NAT connects your virtual machine to the internet only. This hooks into the nating table of your network interface. This is why WLAN adapters and NAT networking on guest are trouble on Linux. Your host and guest share the same IP if look at from outside

  3. NAT networks: same as 2 but all the VMs connected to the same NAT network can talk. From the outside all VMs appear under the same address as your host, whilst having distinct addresses on the NAT network

  4. Bridged this hooks into the packet filtering and forwarding tables of your physical interface. All connected VMs get their own address on the same network as the host. From the out side the appear as separate devices each.

  5. Internal should be self explenatory

While picking the right network type it is important to configure the network settings on the guest properly so they have the proper IP, netmask, default gateway, routes and DNS settings for your applied scenario.

Further information can be found on Chapter 6. Virtual networking of the virtual box documentation. Its quite a tangle of Layer 2, Layer 3 and virtualisation features. One funny thing you can do is setting up tow host only networks with a firewall between them, filtering traffic, that then gets routed via a secondary route through your host system. Then tear your hair out for days, wondering why your firewall rules aren't working.

6
  • The host only network adapter on the host has the IP address 192.168.56.1, the guest has 192.168.56.4, they are the same network so the communication should be bidirectional but I can access host to guest not guest to host. What do I need to add on the guest.
    – Ravi
    Nov 14, 2017 at 11:55
  • The question is what you want to access on the host and what it listens to. If you have lets say a web server on the host, listening on 192.168.0.5 (example for your hosts physical network). You can not reach it from your host only network, because your host does not know where this network is. You have to define a route that tells the host to go ask 192.168.56.1 for a connection to 192.168.0.5 or the network 192.168.0.0/24. Your guest has no clue what sits behind 192.168.56.1, so it assumes its just another computer. Also remember to configure the firewall of your host accordingly.
    – gilgwath
    Nov 14, 2017 at 13:18
  • I am trying to access the Cygwin SSH server. I've set the ListenAddress in sshd_config to 0.0.0.0 so this should make it listen on all addresses including 192.168.56.1 also the firewall is turned off.
    – Ravi
    Nov 15, 2017 at 5:40
  • Can you ping 192.168.56.1 from you VM? What happens if you traceroute 192.168.56.1? Try the same with the address of your physical interface. and report the result :-)
    – gilgwath
    Nov 18, 2017 at 10:18
  • I found the error in your configuration. See the updated post.
    – gilgwath
    Nov 18, 2017 at 18:41
0

The NAT thing was finally clear to me. The host has a NAT network for each of the VMs. I cannot achieve bidirectional communication on any interface but I found the solution. I had to use 3 adapters.

1)NAT: VM to host i.e. ssh 10.0.2.1 and VM to external.

2)Host Only Only for host to VM

3)Internal Guest to guest

In addition to this I configured bind on the host with zones for each of the VMs and the A record of the configured host pointing to the internal network and an A record for the host pointing to the NAT address 10.0.2.1 . This was so that guests can communicate to each other without using IP and for VM to host. Then I put a hosts file on the host with the host IPs of the guests from the host only network to facilitate host to guest. I also made sure the host uses external dns and not the installed bind. Now I don't need to use a hosts file on each VM. This config pretty much satisfies my needs.

2
  • You can also use nat-network for this purpose which creates an isolated network which itself is NATed to your computers ip.
    – jdwolf
    Nov 20, 2017 at 3:40
  • You normally do not need internal network. The host only network includes communication between the guests and the host.
    – EOhm
    Nov 9, 2019 at 20:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .