VirtualBox host-only network, cannot ping host from guest

6,260

Solution 1

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.

Solution 2

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.

Share:
6,260
t7e
Author by

t7e

Updated on September 18, 2022

Comments

  • t7e
    t7e almost 2 years

    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?

    • aderchox
      aderchox over 2 years
      Also notice that Windows firewall blocks icmp echo request by default, so you might need to have a look at that and enable these rules if they're not enabled.
  • t7e
    t7e almost 4 years
    VirtualBox states that it is possible to ping the host from guest in the host-only network mode: virtualbox.org/manual/ch06.html
  • John
    John almost 4 years
    Host Mode is for isolating the guest, so I think the information in the article I posted applies. From your link "Instead, a virtual network interface, similar to a loopback interface, is created on the host, providing connectivity among virtual machines and the host." . So you need the ideas supplied in my answer. I do not think Ping will work.
  • t7e
    t7e almost 4 years
    I need this congif for Wireshark.
  • John
    John almost 4 years
    Try another networking mode to accommodate Wire Shark.
  • t7e
    t7e almost 4 years
    Nothing else is working to catch the traffic from VM to host. It only works backward when I send packets from host to guest. Host-only is the mode everyone suggests for Wireshark to catch traffic from VMs.
  • John
    John almost 4 years
    Host only isolates a guest machine and so hampers traffic flow by design. Why not use an unfettered networking mode for this.
  • Zsolti
    Zsolti over 2 years
    Thanks! In my case the Ubuntu VM couldn't communicate with the MySQL of the host. Added mysqld.exe to the allowed apps in Windows Defender and the connection worked again.