7

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?

t7e
  • 760

4 Answers4

7

I had the same setup - a Windows host with an Ubuntu VM on it. And the same problem. I could ping the guest from the host, but not the other way around. I was using a bridged adapter in the VM settings, and I entirely removed the Host Only adapter VirtualBox created...

The problem turned out to be the Windows Defender Firewall! As a shotgun approach, I just disabled it entirely, and tested... presto!

Ideally, one would want to add a firewall rule to open a pinhole for a specific ip range, port, protocol... Try the shotgun first to see if you have the same essential issue.

BuvinJ
  • 311
3

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.

heavyd
  • 65,321
0

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.

-1

I was facing the same problem, and found this

https://bitlaunch.io/blog/how-to-make-windows-10-pingable/#:~:text=You'll%20be%20taken%20to,allow%20ping%20in%20Windows%2010.

In windows, all you have to do is configure firewal and enable this enter image description here

Hope I've helped