Centos7 with private network lost fixed IP

青春壹個敷衍的年華 提交于 2019-12-05 09:24:59

It seems that's a problem due to DHCP configuration ( issue : https://github.com/mitchellh/vagrant/issues/5590 )

the network service doesn't reload NetworkManager, so it will continue to wait for dhcp lease .. and after dhcp timeout, the fixed ip is removed.

Adding a shell provision script with

sudo nmcli connection reload
sudo systemctl restart network.service

Fixes the problem

EDIT: vagrant 1.7.3+ fixes the bug too ;)

There seems to be a similar issue in newer Vagrant versions (1.9.1).

A pull request that fixes the issue was already merged (not released yet):

https://github.com/mitchellh/vagrant/pull/8148

If you want to apply that fix you can try this (sudo may be required, depending on the file permissions):

  1. Locate you local Vagrant installation (on Fedora it is /opt/vagrant/)
  2. Move to the folder of the vagrant gem:

    cd embedded/gems/gems/vagrant-1.9.1
    
  3. Initialize a new Git Repository and add the GitHub remote:

    git init
    git remote add origin https://github.com/mitchellh/vagrant.git
    git fetch --all
    
  4. Checkout a new branch and reset it to your current release (e.g. 1.9.1).

    If you are unsure if you have local changes do not use --hard and do a git diff / git checkout after the reset:

    git checkout -b hotfixes
    git reset --hard v1.9.1
    
  5. Now apply the hotfix:

    git cherry-pick 96611341a96d7d19fdade5556a110b22c6add22b
    

After that a vagrant reload should bring up the local network just fine.

The fix is mentioned in: https://github.com/mitchellh/vagrant/pull/8148

In /opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/guests/redhat/cap/configure_networks.rb,

add /sbin/ifup '#{network[:device]}' right after nmcli c reload || true.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!