VirtualBox: MacOS host can't connect to guest, but guest can connect to host


Alex G.

My setup:

  • MacOS host (High Sierra 10.13.3)
  • Linux visit (Ubuntu 16.04)
  • Virtual Box 5.2.12
  • NAT networking

I need to talk from host to guest and from guest to internet.

The guest gets IP address 10.0.2.15 and gateway 10.0.2.2. I can ping the host from the guest with no problem. However, I can't ping the guest from the host:

PING 10.0.2.15 (10.0.2.15): 56 data bytes Request timeout for icmp_seq 0 Request timeout for icmp_seq 1 Request timeout for icmp_seq 2...

The 10.0.2.2 address seems to be assigned to my host: I have a httpd server running on the host - if I navigate to 10.0.2.2 from a guest browser, I get the host's site.

Looking at the network configuration, I can't see any interfaces added by virtualbox:

host$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
OHC4: flags=0<> mtu 0
EHC36: flags=0<> mtu 0
EHC38: flags=0<> mtu 0
OHC6: flags=0<> mtu 0
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether xxxxx 
    inet6 fe80::1c34:9a51:ed93:3a5b%en1 prefixlen 64 secured scopeid 0x9 
    inet 10.37.37.37 netmask 0xffffff00 broadcast 10.37.37.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304
    ether xxxxx
    media: autoselect
    status: inactive
fw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 4078
    lladdr xxxxx
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect <full-duplex>
    status: inactive
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    options=b<RXCSUM,TXCSUM,VLAN_HWTAGGING>
    ether xxxxx
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect (none)
    status: inactive
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
    inet6 fe80::9a23:8dd9:bf4e:f69d%utun0 prefixlen 64 scopeid 0x8 
    nd6 options=201<PERFORMNUD,DAD>

And I don't see any route from host to guest:

host$ netstat -nr
Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            10.37.37.1         UGSc           77       10     en1
10.37.37/24        link#9             UCS             3        0     en1
127                127.0.0.1          UCS             0        0     lo0
127.0.0.1          127.0.0.1          UH              3   458010     lo0
169.254            link#9             UCS             0        0     en1
255.255.255.255/32 link#9             UCS             0        0     en1

Internet6:
Destination                             Gateway                         Flags         Netif Expire
default                                 fe80::%utun0                    UGcI          utun0
::1                                     ::1                             UHL             lo0
fe80::%lo0/64                           fe80::1%lo0                     UcI             lo0
fe80::1%lo0                             link#1                          UHLI            lo0
fe80::%utun0/64                         fe80::9a23:8dd9:bf4e:f69d%utun0 UcI           utun0
fe80::9a23:8dd9:bf4e:f69d%utun0         link#8                          UHLI            lo0
fe80::%en1/64                           link#9                          UCI             en1
fe80::1c34:9a51:ed93:3a5b%en1           f0:b4:79:1f:81:f0               UHLI            lo0
ff01::%lo0/32                           ::1                             UmCI            lo0
ff01::%utun0/32                         fe80::9a23:8dd9:bf4e:f69d%utun0 UmCI          utun0
ff01::%en1/32                           link#9                          UmCI            en1
ff02::%lo0/32                           ::1                             UmCI            lo0
ff02::%utun0/32                         fe80::9a23:8dd9:bf4e:f69d%utun0 UmCI          utun0
ff02::%en1/32                           link#9                          UmCI            en1

It is understandable that the host cannot talk to the guests. The question is how can I do this?

Alex G.

Eventually I did figure it out. The trick is to create a host-only network, then add two network interfaces in the guest - one for the host-only network and one for using NAT. Now, the NAT interface allows the guest to access the Internet, while the host-only interface allows two-way communication between the host and the guest.

Related


Can't access USB UART in VirtualBox Guest on macOS host

Martin I have created a virtualbox via docker-machine: $ docker-machine create --driver virtualbox default In the guest OS, I want to access my USB serial device, which is the Nordic nRF52840 DevKit, listed in macos /dev/tty.usbmodem144241. However, virtualbox

Can't access USB UART in VirtualBox Guest on macOS host

Martin I have created a virtualbox via docker-machine: $ docker-machine create --driver virtualbox default In the guest OS, I want to access my USB serial device, which is the Nordic nRF52840 DevKit, listed in macos /dev/tty.usbmodem144241. However, virtualbox

Can't access USB UART in VirtualBox Guest on macOS host

Martin I have created a virtualbox via docker-machine: $ docker-machine create --driver virtualbox default In the guest OS, I want to access my USB serial device, which is the Nordic nRF52840 DevKit, listed in macos /dev/tty.usbmodem144241. However, virtualbox

Can't access USB UART in VirtualBox Guest on macOS host

Martin I have created a virtualbox via docker-machine: $ docker-machine create --driver virtualbox default In the guest OS, I want to access my USB serial device, which is the Nordic nRF52840 DevKit, listed in macos /dev/tty.usbmodem144241. However, virtualbox

VirtualBox: Ubuntu guest can't connect to internet

albert I have configured the Ubuntu server (guest) with a NAT adapter and configured it in / etc/network/interfaces like this: auto enp0s3 iface enp0s3 inet dhcp But not connected to the internet: ping www.google.com ping: unknown host www.google.com The hos

Connect to host from VirtualBox guest OS?

Naftuli Kay I essentially want to access my host from a guest in VirtualBox. Is there an IP address for my host that I can use from the guest? Are additional steps required to set this up? I want to access the host's Apache, FTP and SSH services. Naftuli Kay T

Connect to host from VirtualBox guest OS?

Naftuli Kay I essentially want to access my host from a guest in VirtualBox. Is there an IP address for my host that I can use from the guest? Are additional steps required to set this up? I want to access the host's Apache, FTP and SSH services. Naftuli Kay T

OpenVPN server on Virtualbox Guest. Can connect but can't ping

Phlebas As a development environment for a production server, I've setup a Virtualbox guest. However, I am unable to setup an OpenVPN server. I can connect to my VPN using (KDE NetworkManager) with no problem, but after that I can't even ping the VPN host. Fro

OpenVPN server on Virtualbox Guest. Can connect but can't ping

Phlebas As a development environment for a production server, I've setup a Virtualbox guest. However, I am unable to setup an OpenVPN server. I can connect to my VPN using (KDE NetworkManager) with no problem, but after that I can't even ping the VPN host. Fro

VirtualBox Windows 7 host, XP Guest can't play audio

DCookie As the topic says, I can't get the XP guest to produce sound on a Windows 7 Ultimate 32-bit host. The sound works fine on the host OS. If the host audio driver is set to "null audio driver" and the audio controller is set to ICH AC97, everything seems

VirtualBox Windows 7 host, XP Guest can't play audio

DCookie As the topic says, I can't get the XP guest to produce sound on a Windows 7 Ultimate 32-bit host. The sound works fine on the host OS. If the host audio driver is set to "null audio driver" and the audio controller is set to ICH AC97, everything seems

Connect via COM port between host and guest in VirtualBox

s I'm running an application on Ubuntu (16.04) in VirtualBox, and VirtualBox on Windows 10 (host). In Simulink (running on the host) I run a simulation and in the last stage I collect some values. I want to output these values to an application running on Virt

Connect via COM port between host and guest in VirtualBox

s I'm running an application on Ubuntu (16.04) in VirtualBox, and VirtualBox on Windows 10 (host). In Simulink (running on the host) I run a simulation and in the last stage I collect some values. I want to output these values to an application running on Virt

Connect via COM port between host and guest in VirtualBox

s I'm running an application on Ubuntu (16.04) in VirtualBox, and VirtualBox on Windows 10 (host). In Simulink (running on the host) I run a simulation and in the last stage I collect some values. I want to output these values to an application running on Virt

Connect via COM port between host and guest in VirtualBox

s I'm running an application on Ubuntu (16.04) in VirtualBox, and VirtualBox on Windows 10 (host). In Simulink (running on the host) I run a simulation and in the last stage I collect some values. I want to output these values to an application running on Virt