Unable to access VMs using host-only adapter

Discussions related to using VirtualBox on Mac OS X hosts.
Post Reply
agodfrin
Posts: 37
Joined: 4. Jul 2012, 19:14
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: WinXP, Linux,Win7
Location: Nice, France

Unable to access VMs using host-only adapter

Post by agodfrin »

My problem is simple: I am unable to connect to any of my VMs using the host-only adapter.
All pings from my MacOS host fail like this:

Code: Select all

$ ping 192.168.56.101
PING 192.168.56.101 (192.168.56.101): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
^C
This definitely used to work. One of my VMs runs an Oracle database and I have been connecting to it from my host using sqlplus. Another one runs an application server and I have also been using it from my host. Somehow that all stopped working, but I can't pin the change to something I did: I have been upgrading VirtualBox as new versions and fixes came out. Maybe one of them caused that change ? I am on 4.3.6 r91406 now. I also upgraded MacOSX to 10.9.1 and maybe that caused the change ? I don't connect to VMs all that much, so I can't say when exactly I started having the problem.

I first thought that something like a firewall was blocking access in the VMs, but that is not the case: I can ping each VM from any of the others. Only pings from the host fail. The VMs have different OS's: XP, W7, Linux.

My host-only adapter is like this:

Code: Select all

$ vboxmanage list hostonlyifs
Name:            vboxnet0
GUID:            786f6276-656e-4074-8000-0a0027000000
DHCP:            Disabled
IPAddress:       192.168.56.1
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:00
MediumType:      Ethernet
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet0
There seems to be something on the MacOS host that prevents connections from reaching VMs. A traceroute shows this:

Code: Select all

$ traceroute  192.168.56.101
traceroute to 192.168.56.101 (192.168.56.101), 64 hops max, 52 byte packets
 1  192.168.0.254 (192.168.0.254)  4.483 ms  1.240 ms  1.150 ms
 2  82.236.10.254 (82.236.10.254)  19.623 ms  20.419 ms  20.750 ms
 3  * *^C
192.168.0.254 is the gateway on my LAN and 82.236.10.254 is the external (public) IP address of my router. That seems to indicate a problem with routes. Indeed the route to the virtual gateway of the host only adapter is wrong:

Code: Select all

route get 192.168.56.1
   route to: 192.168.56.1
destination: default
       mask: default
    gateway: 192.168.0.254
  interface: en1
      flags: <UP,GATEWAY,DONE,STATIC,PRCLONING>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500         0 
Not sure how that came to be ...
agodfrin
Posts: 37
Joined: 4. Jul 2012, 19:14
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: WinXP, Linux,Win7
Location: Nice, France

Re: Unable to access VMs using host-only adapter

Post by agodfrin »

OK - got it working now. I ended up deleting the host-only interface I was using (vboxnet0) and redefining it exactly the same way, and now everything works again. I have the proper route to the host-only gateway:

Code: Select all

$ route get 192.168.56.1
   route to: 192.168.56.1
destination: 192.168.56.1
  interface: lo0
      flags: <UP,HOST,DONE,LLINFO,WASCLONED,LOCAL,IFSCOPE,IFREF>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0     16384         0
And also to the guest VM: it now goes via the vboxnet0 interface.

Code: Select all

$ route get 192.168.56.101
   route to: 192.168.56.101
destination: 192.168.56.101
  interface: vboxnet0
      flags: <UP,HOST,DONE,LLINFO,WASCLONED,IFSCOPE,IFREF>
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500      1045 
And routing and pinging now work fine again:

Code: Select all

$ ping 192.168.56.101
PING 192.168.56.101 (192.168.56.101): 56 data bytes
64 bytes from 192.168.56.101: icmp_seq=0 ttl=128 time=0.938 ms
64 bytes from 192.168.56.101: icmp_seq=1 ttl=128 time=0.464 ms
^C
--- 192.168.56.101 ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.464/0.701/0.938/0.237 ms

$ traceroute 192.168.56.101
traceroute to 192.168.56.101 (192.168.56.101), 64 hops max, 52 byte packets
 1  192.168.56.101 (192.168.56.101)  0.797 ms *  0.577 ms
So deleting and redefining the host-only adapter did the trick. Note that I had to do this via the GUI. Using vboxmanage hostonlyif remove and create somehow did not solve the problem.
agodfrin
Posts: 37
Joined: 4. Jul 2012, 19:14
Primary OS: Mac OS X other
VBox Version: OSE other
Guest OSses: WinXP, Linux,Win7
Location: Nice, France

Re: Unable to access VMs using host-only adapter

Post by agodfrin »

And here is the final explanation for this behavior. I think I have it nailed down.

When I moved to Mavericks I started having the problem of VMs no longer properly shutting down. Or rather, the virtual box process for the VM did not shutdown. The workaround was to manually remove and redefine the vboxnet0 adapter, which I did using the vboxmanage hostonlyif remove and create commands.

The trouble is that I had not realized that the "create" command only creates the vboxnet0 adapter, but does not configure it. I just added the following two commands:

Code: Select all

VBoxmanage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1
VBoxmanage dhcpserver modify --ifname vboxnet0 --ip 192.168.56.100 --netmask 255.255.255.0                      --lowerip 192.168.56.101 --upperip 192.168.56.127 --enable
The vboxnet0 interface is now fully configured and everything works fine.

Then again, the workaround of dropping/recreating the vboxnet0 adapter is no longer needed anyway (virtual box on Mavericks now correctly stops VMs).
Post Reply