Page 1 of 1

Unable to connect between guests via host-only adapter

Posted: 27. Jun 2015, 07:41
by jilebedev
Host: OSX Yosemite 10.10.3
Guest1: CentOS 7.1
Guest2: CentOS 7.1

Problem: guest1 cannot ping/ssh/etc guest2, or vice versa.

What does work:
1. The host can ssh and ping each of the guests.
2. The guests can ping the host.
3. The host and the guests can reach the internet. (Guests via a NAT adapter)

Guest networking configuration:
DHCP: Off. (VirtualBox's DHCP server for the host-only adapter is turned off.)
guest1 IP: 192.168.56.10/24
guest2 IP: 192.168.56.11/24
Broadcast: 192.168.56.255

Routes:
The NAT adapter interface on the guests contains a default gateway: 10.0.2.2
I can't have two default gateways, so for the host-only-adapter interface, I've added a static route to the 192.168.56.0/24 network via the host-only-adapter IP 192.168.56.1:
The file: /etc/sysconfig/network-scripts/route-enp0s8:
Contents: 192.168.56.0/24 via 192.168.56.1

The routing table on both guests is identical -- here it is:

Code: Select all

[root@guest1 ~]# ip route
default via 10.0.2.2 dev enp0s3  proto static  metric 101 
10.0.2.0/24 dev enp0s3  proto kernel  scope link  src 10.0.2.15  metric 100 
192.168.56.0/24 via 192.168.56.1 dev enp0s8  proto static  metric 100 
[root@guest1 ~]# 
ARP troubleshooting:
The information from both guests is identical:

Code: Select all

[root@guest1 ~]# arp -i enp0s8 192.168.56.1
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.56.1             ether   0a:00:27:00:00:00   C                     enp0s8
[root@guest1 ~]# arp -i enp0s8 192.168.56.10
192.168.56.10 (192.168.56.10) -- no entry
[root@guest1 ~]# arp -i enp0s8 192.168.56.11
192.168.56.11 (192.168.56.11) -- no entry
[root@guest1 ~]# 

Does anyone know what I could be doing wrong?


-----------------------------------------------------------------
-----------------------------------------------------------------
-----------------------------------------------------------------

Solution:
1. Ensure no gateway is present in the configuration of the host-only-adapter interface on the guest. (For CentOS 7.x, use nmcli or nmtui to remove the gateway configuration.)
2. Ensure no routes are statically specified via /etc/syconfig/network-scripts/route-<ifname> (

At this point, a default route will be added like this:
ip route:192.168.56.0/24 dev enp0s8 proto kernel scope link src 192.168.56.10 metric 100
route: 192.168.56.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s8

You'll know you've done it wrong when route -n shows the G (for default gateway) flag on more than one interface. You can't have more than one default gateway.
A host-only-adapter from VirtualBox is not a router - it's a switch. Its purpose isn't to route packets - it's to send them to the appropriate place on the local (192.168.56.0/24) network. My networking knowledge is a bit shaky, but that's the best I I could discern from the VirtualBox Chapter 6 (Networking) documentation.

Re: Unable to connect between guests via host-only adapter

Posted: 27. Jun 2015, 13:49
by Perryg
Host-only does not use a gateway. Remove it and you should see the guests able to communicate, because now you have them looking for something that does not exist to get to each other.

Re: Unable to connect between guests via host-only adapter

Posted: 27. Jun 2015, 18:47
by jilebedev
Thanks for the help PerryG. That's exactly what it was.

I'll update the original post to help the next poor bastard with the solution.