TransWikia.com

VirtualBox host-only network, cannot ping host from guest

Super User Asked by t7e on December 24, 2020

I have the following setup:
Host machine Windows:

   IPv4 Address. . . . . . . . . . . : 192.168.0.103
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.0.1

Guest machine Ubuntu in VirtualBox:

2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:01:85:e3 brd ff:ff:ff:ff:ff:ff
    inet 192.168.33.3/24 brd 192.168.33.255 scope global dynamic enp0s3
       valid_lft 359sec preferred_lft 359sec
    inet6 fe80::a00:27ff:fe01:85e3/64 scope link
       valid_lft forever preferred_lft foreve

VirtualBox Host-Only Ethernet Adapter:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::1454:89c9:eb7c:9d6d%37
   IPv4 Address. . . . . . . . . . . : 192.168.33.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

VirtualBox DHCP:

Server 192.168.33.2
Mask 255.255.255.0
Lower addr 192.168.33.3
Upper addr 192.168.33.254

I can easily ping from the Host machine Windows to the guest:

ping 192.168.33.3

Pinging 192.168.33.3 with 32 bytes of data:
Reply from 192.168.33.3: bytes=32 time<1ms TTL=64
Reply from 192.168.33.3: bytes=32 time<1ms TTL=64
Reply from 192.168.33.3: bytes=32 time<1ms TTL=64

It does not work for me otherwise. Namely, I cannot ping from the Guest Ubuntu to the Host Windows:

ping 192.168.0.103
ping: connect: Network is unreachable

P.S. I even tried to modify the guest’s address to 192.168.0.3 to match the host’s network and the actual result was the same:
I could not ping from the Guest Ubuntu to the Host Windows machine 192.168.0.103.

However, the guest (Ubuntu) can ping VirtualBox Host-Only Ethernet Adapter:

ping 192.168.33.1
PING 192.168.33.1 (192.168.33.1) 56(84) bytes of data.
64 bytes from 192.168.33.1: icmp_seq=1 ttl=128 time=0.378 ms
64 bytes from 192.168.33.1: icmp_seq=2 ttl=128 time=0.430 ms

VirtualBox has this table:
https://www.virtualbox.org/manual/ch06.html

Host-only:
VM→Host +
VM←Host +
VM1↔VM2 +
VM→Net/LAN -
VM←Net/LAN -

Is it normal VirtualBox behavior? (I saw threads that people can ping from guest to host in this mode).
What am I missing?

2 Answers

Your host PC has multiple networking interfaces and multiple IP addresses. Its difficult to say for sure, but based on the information you've provided it looks like the IP 192.168.0.103 is likely your standard network interface. VirtualBox has created a second network interface called the "VirtualBox Host-Only Ethernet Adapter" and given that adapter the IP of 192.168.33.1.

Since you can ping 192.168.33.1 from your guest VM you CAN ping the host computer from the guest, but you can only ping the interface/IP that is shared with the VM. Your PC will not route the network traffic from the host-only interface to your real network interface.

As for capturing traffic using Wireshark, it appears the Wireshark can only use physical interfaces and the host-only interface is a software interface created by VirtualBox so you likely won't be able to capture from it.

Answered by heavyd on December 24, 2020

That is normal for Host Only mode in Virtual Box.

https://condor.depaul.edu/glancast/443class/docs/vbox_host-only_setup.html#:~:text=With%20host%2Donly%20networking%2C%20virtual,in%20VirtualBox%20on%20the%20host.

A VirtualBox host-only adapter can also function as a DHCP server to assign ip addresses to VirtualBox virtual machines. The host machine (and other virtual machines if any) can then connect to the virtual machines using these ip addresses using ssh or sftp (provided an ssh server is running on the virtual machine).

This does mean virtual machines using host-only can't access the outside world, but in particular, the host should be able to use ssh to login to a virtual machine (with an ssh server running) and sftp to transfer files between the host and the virtual machine.

Consider using Bridged or NAT mode if you wish to interconnect. That will work.

Answered by John on December 24, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP