Vagrant: centos box and private network lost IP

Created on 5 Sep 2015  路  5Comments  路  Source: hashicorp/vagrant

With this vagrant file :

Vagrant.configure(2) do |config|

  config.vm.box = "centos7"
  config.vm.hostname = "docker-registry"
  config.vm.box_url = "https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box"

  #config.vm.network "public_network"
  config.vm.network "private_network", ip: "192.168.100.20"
  #config.vm.synced_folder ".", "/vagrant", type: "nfs"

  # VirtualBox
  config.vm.provider :virtualbox do |vb|
    vb.name = "poc_docker"
    vb.memory = 3072
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
  end


end

The ping respond first at "192.168.100.20", but failed after some time.
When I connect on the box, it seems that the ip is lost.

sudo /sbin/ifup eth1

or a reboot fix the problem.

But what's the root cause ? Any ideas ?
Where am I wrong in my Vagrantfile ?

bug

Most helpful comment

Hi,

I will try to reproduce, but I've upgraded my virtualbox. So I am not sure it is always present.
The problem was that Vagrant fixes the IP, but the network service was not reloaded, so for CentOS, the interface was alwaws manage by DHCP ...
And after dhcp timeout, the network interface was putting down.

This provision script fixed my problem :

sudo nmcli connection reload
sudo systemctl restart network.service

All 5 comments

Hi @gcuisinier

Thank you for opening an Issue, and I am sorry you are experiencing problems with Vagrant. I just ran your exact Vagrantfile on Vagrant 1.7.4, Virtualbox 5.0.8 r103449 for over 2 hours and the box is still pingable.

Are you able to share any additional information, such as the debug logs from the Vagrant run?

Hi,

I will try to reproduce, but I've upgraded my virtualbox. So I am not sure it is always present.
The problem was that Vagrant fixes the IP, but the network service was not reloaded, so for CentOS, the interface was alwaws manage by DHCP ...
And after dhcp timeout, the network interface was putting down.

This provision script fixed my problem :

sudo nmcli connection reload
sudo systemctl restart network.service

I'm seeing a similar issue. After some time the private network interface doesn't have an IP address. I've also noticed that the network service is down. I'm trying to run github.com/cloudbase/salt-openstack on this which requires the NetworkManager to be off.
EDIT: After running 'sudo systemctl start network' on the guest, the IP returns (even though network.service fails)

This has been fixed. I forget the issue, but we now are very careful with nmcli.

Will be released in Vagrant 1.8!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StefanScherer picture StefanScherer  路  3Comments

bbaassssiiee picture bbaassssiiee  路  3Comments

janw-me picture janw-me  路  3Comments

tomhking picture tomhking  路  3Comments

rhencke picture rhencke  路  3Comments