Vagrant 具有专用网络的Centos7丢失了固定IP
我有一个centos7流浪者包厢的网络问题。 当我使用固定IP设置一个专用网络时,这个网络首先绑定良好,但几秒钟/分钟后就会丢失Vagrant 具有专用网络的Centos7丢失了固定IP,vagrant,vagrantfile,centos7,Vagrant,Vagrantfile,Centos7,我有一个centos7流浪者包厢的网络问题。 当我使用固定IP设置一个专用网络时,这个网络首先绑定良好,但几秒钟/分钟后就会丢失 vagrant up ==> default: Forcing shutdown of VM... ==> default: Destroying VM and associated drives... ==> default: Running cleanup tasks for 'shell' provisioner... Bringin
vagrant up
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
==> default: Running cleanup tasks for 'shell' provisioner...
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'sfeirbenelux/centos7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'sfeirbenelux/centos7' is up to date...
==> default: Setting the name of the VM: poc_docker
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2200 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2200
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if its present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 5.0.2
default: VirtualBox Version: 4.3
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Running provisioner: shell...
default: Running: inline script
==> default: net.ipv4.ip_forward = 1
==> default: Setting up swapspace version 1, size = 2097148 KiB
==> default: no label, UUID=170723d8-1782-4915-a877-4d9874ac7396
➜ install git:(master) ✗ ping 192.168.100.20
PING 192.168.100.20 (192.168.100.20): 56 data bytes
64 bytes from 192.168.100.20: icmp_seq=0 ttl=64 time=0.390 ms
64 bytes from 192.168.100.20: icmp_seq=1 ttl=64 time=0.252 ms
64 bytes from 192.168.100.20: icmp_seq=2 ttl=64 time=0.461 ms
^C
--- 192.168.100.20 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.252/0.368/0.461/0.087 ms
➜ install git:(master) ✗ ping 192.168.100.20
PING 192.168.100.20 (192.168.100.20): 56 data bytes
64 bytes from 192.168.100.20: icmp_seq=0 ttl=64 time=0.273 ms
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
使用此流浪者文件:
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
当我连接到盒子上时,似乎ip丢失了
sudo /sbin/ifup eth1
暂时修复该问题,但IP会再次丢失。
重新启动该框(vagrant halt&&vagrant up)似乎可以永久解决问题。
我试图用Packer()创建一个定制的centos 7 box,我也复制了这个问题
我想这是Centos 7的具体问题吧?
你已经有同样的问题了吗?有没有办法通过添加一个vagrant命令来解决这个问题
我的环境:
约塞米蒂
➜ ~ 流浪汉版
流浪汉1.7.2
➜ ~ VBoxManage--版本
4.3.26R988这似乎是由于DHCP配置造成的问题(问题:) 网络服务不会重新加载NetworkManager,因此它将继续等待dhcp租约。。dhcp超时后,固定ip被删除 使用添加shell提供脚本
sudo nmcli connection reload
sudo systemctl restart network.service
解决了这个问题
编辑:
vagrant 1.7.3+也修复了该漏洞;) 在更新的Vagrant版本(1.9.1)中似乎也存在类似的问题 修复该问题的拉取请求已合并(尚未发布): 如果要应用该修复程序,可以尝试以下操作(sudo可能是必需的,具体取决于文件权限):
/opt/Vagrant/
)cd embedded/gems/gems/vagrant-1.9.1
git init
git remote add origin https://github.com/mitchellh/vagrant.git
git fetch --all
--hard
执行git diff
/git签出
:
git checkout -b hotfixes
git reset --hard v1.9.1
git cherry-pick 96611341a96d7d19fdade5556a110b22c6add22b
/opt/vagrant/embedded/gems/gems/vagrant-1.9.1/plugins/guests/redhat/cap/configure_networks.rb
中
在
nmcli c reload | | | true
之后添加/sbin/ifup'{network[:device]}'
,奇怪的是,我的设置几乎相同,但仍然运行centos 6.5,而且工作正常。你能把你运行的shell脚本放进去吗?它会扰乱网络吗?此外,您还可以升级虚拟机Guestadition,因为我已经删除了shell脚本。还是sameThank谢谢你发这个帖子。我花了一天的大部分时间试图解决这个问题。这解决了很多问题。我真的不明白为什么这个修补程序在11天前被合并了,但它仍然没有在可下载的二进制文件中。这似乎是一个非常重要的问题。这只是救了我的命。非常感谢!是的,这为我修复了它,使用Centos 7和Vagrant 1.9.1。在1.9.1上为我工作,使用网站上的基本Centos box安装