Vagrant on Ubuntu 17.04: no communication between host and guest (private network)
This problem took several hours to work out, so am posting the solution here. The problem was that, with an Ubuntu 17.04 host and Vagrant (1.9.2) and an Ubuntu 16.04 guest (ubuntu/xenial64
) communication between the host and guest wasn't working when networking was setup with a private network like this:
config.vm.network "private_network", ip: "192.168.33.10"
It worked after the first vagrant up
but after rebooting and/or running vagrant halt
— then vagrant up — the guest and host could not communicate with each other over the private network.
ping 192.168.33.1
Wouldn't work from the guest and:
ping 192.168.33.10
Wouldn't work from the host.
Solution
Open a command prompt, enter:
ip addr
In the output, look for the VirtualBox network, probably vboxnet0
(or something similar). If it looks something like this:
vboxnet0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0a:00:27:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.33.1/24 scope global vboxnet0
valid_lft forever preferred_lft forever
Where 'state' in the first line is 'DOWN' then the interface needs to be brought up; run this command (changing vboxnet0
to the name found by running ip addr if required):
sudo ip link set vboxnet0 up
Other stuff I tried (might be useful if the above didn't work):
- In VirtualBox, going to File -> Preferences -> Network -> Host-only Networks -> vboxnet0 and clicking the screwdriver/spanner to edit the network, then click 'OK' and 'OK' on both open dialogues,
this gets VirtualBox to recreate the network. - Running
vagrant plugin install vagrant-vbguest
at the command prompt on the host machine. This seems to ensure the VirtualBox Guest Additions are installed. - Updating guest additions to the latest version.
- Re-installing the VirtualBox driver by running the command:
sudo rcvboxdrv setup
on the host. - Ensuring firewall is disabled using the commands
sudo ufw disable
and disabling iptables.
a Padded Cell our articles site!