2

I am using VirtualBox 5.0.20. The host machine is a MacBook running OS X 10.11.5 (El Capitan). The guest OS is 64-bit Arch Linux. When I installed Arch from the ISO, the guest's internet connectivity was fine. However, once I booted into the installed system, I could no longer reach the internet (for example, pinging 8.8.8.8 just hangs indefinitely).

The virtual machine has two network adapters: one bridged and one host-only. I have tried changing the bridged to a NAT adapter, as well as connecting the bridge at one time to the host's wireless interface and at another time to the host's wired interface. The guest cannot access the internet under any of these setups.

The guest OS has enabled systemd-networkd.service and systemd-resolved.service. It does not have any other network service enabled that I am aware of. If possible, I would like to stick to these services, rather than switch to a different service, but I will switch if there is some inherent flaw in these services that is the root of my problem.

Within the guest OS, the contents of the bridged adapter's network file:

[root@arch64 ~]# cat /etc/systemd/network/bridged.network 
[Match]
Name=enp0s3

[Network]
DHCP=ipv4

And the contents of the host-only adapter's network file:

[root@arch64 ~]# cat /etc/systemd/network/host-only.network 
[Match]
Name=enp0s8

[Network]
Address=192.168.56.2/24
Gateway=192.168.56.1

The bridged adapter successfully acquires a DHCP lease and I can additionally ping hosts on my LAN, but I cannot ping anything beyond my LAN's router. The host's internet connection is fine.

More info:

[root@arch64 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:1a:7d:74 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.5/24 brd 192.168.0.255 scope global dynamic enp0s3
       valid_lft 3598sec preferred_lft 3598sec
    inet6 fe80::a00:27ff:fe1a:7d74/64 scope link 
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:3c:0a:7d brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.2/24 brd 192.168.56.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe3c:a7d/64 scope link 
       valid_lft forever preferred_lft forever

[root@arch64 ~]# ip route
default via 192.168.56.1 dev enp0s8  proto static 
default via 192.168.0.1 dev enp0s3  proto dhcp  src 192.168.0.5  metric 1024 
192.168.0.0/24 dev enp0s3  proto kernel  scope link  src 192.168.0.5 
192.168.0.1 dev enp0s3  proto dhcp  scope link  src 192.168.0.5  metric 1024 
192.168.56.0/24 dev enp0s8  proto kernel  scope link  src 192.168.56.2 
6
  • Okay, I've added the output from both commands. enp0s3 is the bridged adapter (adapter 1 in VirtualBox settings).
    – kvndrsy
    Commented Jun 15, 2016 at 17:53
  • (@garethTheRed) and enp0s3 is the VirtualBox 'host-only' network (recognized by distinctive subnet 192.168.56.0/24) which means 'can't reach outside'. You don't ever want a default route (aka gateway) to host-only, but I don't know the way to tell Arch that. Commented Jun 15, 2016 at 21:06
  • @garethTheRed When I disable the host-only adapter, I am able to access the internet over the bridged adapter. I have the host-only adapter set up in order to supply a static IP address to the virtual machine that I can access it by (such as for ssh), as the VM is hosted on a laptop that moves between networks. Is there a way I can change the bridged adapter to be the preferred route instead of the host-only adapter?
    – kvndrsy
    Commented Jun 16, 2016 at 11:40
  • @garethTheRed I'm using systemd-networkd.
    – kvndrsy
    Commented Jun 16, 2016 at 14:20
  • @garethTheRed So simple, yet so effective. Thank you! How should I mark this question as answered? Should I answer it myself and just include the tip you gave me?
    – kvndrsy
    Commented Jun 16, 2016 at 14:57

1 Answer 1

2

Per my setup, I had two systemd network unit files: one for the bridged adapter and one for the host-only adapter. I wanted the bridged adapter to have a dynamic address because the virtual machine is on a laptop that moves between networks, and I wanted the host-only adapter to have a static address so that I could access it, such as by ssh, without having to manually determine the address.

However, in creating the network unit files, I blindly copied what I found in a wiki tutorial—one section describing how to quickly set up a dynamic address, the other how to quickly set up a static address. Obviously, the tutorial assumed I would use one or the other simple setup—not both side-by-side, which is a more complex scenario.

Suffice to say that the host-only adapter's network file had the Gateway option specified, while the bridged adapter's file did not. So it appears that the host-only adapter's gateway became the preferred route for traffic coming from the virtual machine. Removing this option from the network file resolved the issue.

Host-only adapter network file after fix (removed the Gateway option):

[root@arch64 ~]# cat /etc/systemd/network/host-only.network 
[Match]
Name=enp0s8

[Network]
Address=192.168.56.2/24
1
  • Same occurs and can be solved same way under Fedora 4.2.3-300.fc23.x86_64. Remove gateway from settings (can also be done via GUI if X is running).
    – h22
    Commented Sep 27, 2016 at 8:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .