具有专用网络的Centos7丢失了固定IP [英] Centos7 with private network lost fixed IP

查看:107
本文介绍了具有专用网络的Centos7丢失了固定IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个带有centos7流浪者盒子的网络问题。
当我建立一个具有固定IP的专用网络时,该网络首先绑定良好,但在几秒钟/分钟后便迷路了。

 无家可归
==>默认值:强制关闭VM ...
==>默认值:销毁VM和关联的驱动器...
==>默认值:运行 shell配置程序的清理任务...
通过 virtualbox提供程序使计算机默认启动...
==>默认值:导入基本框 sfeirbenelux / centos7 ...
==>默认值:用于NAT网络的匹配MAC地址...
==>默认值:检查框 sfeirbenelux / centos7是否为最新...
==>默认值:设置虚拟机的名称:poc_docker
==>默认值:固定端口冲突为22 => 2222。现在在端口2200上。
==>默认值:清除任何先前设置的网络接口...
==>默认:根据配置准备网络接口...
默认:适​​配器1:nat
默认:适​​配器2:仅主机
==>默认值:转发端口...
默认值:22 => 2200(适配器1)
==>默认值:运行预启动 VM自定义...
==>默认值:正在启动VM ...
==>默认值:等待计算机启动。这可能需要几分钟......
默认值:SSH地址:127.0.0.1:2200
默认值:SSH用户名:vagrant
默认值:SSH身份验证方法:私钥
默认值:警告:连接超时。正在重试...
默认值:
默认值:检测到游荡的不安全密钥。 Vagrant将自动替换默认的
:使用新生成的密钥对替换此密钥,以提高安全性。
默认值:
默认值:在来宾中插入生成的公共密钥...
默认值:从来宾中删除不安全的密钥(如果存在)...
默认值:插入了密钥!使用新的SSH密钥断开连接并重新连接...
==>默认值:计算机已启动并准备就绪!
==>默认值:正在检查VM中的来宾添加...
默认值:此VM上的来宾添加与
的安装版本不匹配默认值:VirtualBox!在大多数情况下,这很好,但在极少数情况下,它可以默认
:防止诸如共享文件夹之类的事情正常工作。如果您看到
默认值:共享文件夹错误,请确保
默认值:虚拟机中的来宾添加项与您在
默认值上安装的VirtualBox的版本匹配:主机并重新加载VM 。
默认值:
默认值:Guest Additions版本:5.0.2
默认值:VirtualBox版本:4.3
==>默认值:设置主机名...
==>默认值:配置和启用网络接口...
==>默认值:运行预配器:shell ...
默认值:运行:内联脚本
==>默认值:net.ipv4.ip_forward = 1
==>默认值:设置交换空间版本1,大小= 2097148 KiB
==>默认值:无标签,UUID = 170723d8-1782-4915-a877-4d9874ac7396
➜install git:(master)✗ping 192.168.100.20
Ping 192.168.100.20(192.168.100.20):56个数据字节
从192.168.100.20开始的64字节:icmp_seq = 0 ttl = 64时间= 0.390毫秒ms
从192.168.100.20开始的icb_seq = 1 ttl = 64时间= 0.252毫秒
从192.168.64开始的字节100.20:icmp_seq = 2 ttl = 64时间= 0.461 ms
^ C
--- 192.168.100.20 ping统计信息---
发送了3个数据包,收到了3个数据包,丢失了0.0%
往返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个数据字节
来自192.168.100.20的64个字节:icmp_seq = 0 ttl = 64 time = 0.273 ms
icmp_seq 1的请求超时
icmp_seq 2的请求超时
的请求超时对于icmp_seq 3
对于icmp_seq 4的请求超时

使用该游标文件:

  vagrant.configure(2)做| con图| 

config.vm.box = centos7
config.vm.hostname =码头工人注册表
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专用网络,ip: 192.168.100.20
#config.vm.synced_folder。, / vagrant,键入: nfs

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



结束

当我在盒子上连接时,似乎ip丢失了。

  sudo / sbin / ifup eth1 

临时解决问题,但IP再次丢失。
重新启动机器(无用的停止和无用的操作)似乎可以永久解决此问题。
我尝试用Packer创建一个自定义centos 7框( https:// atlas .hashicorp.com / sfeirbenelux / boxes / centos7 ),我也重现了该问题。



我想这是Centos 7特有的问题?
您已经有同样的问题吗?有没有办法通过添加一个无业游民的命令来解决此问题?



我的环境:



OS X Yosemite
➜〜vagrant --version
Vagrant 1.7.2
➜〜VBoxManage --version
4.3.26r98988

解决方案

由于DHCP配置,这似乎是一个问题(问题: https: //github.com/mitchellh/vagrant/issues/5590



网络服务不会重新加载NetworkManager,因此它将继续等待dhcp

添加带有



<$ p的shell配置脚本。



$ p> sudo nmcli连接重载
sudo systemctl restart network.service

解决问题



编辑
流浪者1.7.3+也修复了该错误;)


I've a network issue with a centos7 vagrant box. When I setup a private network, with fixed IP, this one is well binding first, but get lost after some seconds/minutes.

 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

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

When I connect on the box, it seems that the ip is lost.

sudo /sbin/ifup eth1

Fix the problem temporary, but the IP get losts sometime again. Rebooting the box (vagrant halt && vagrant up) seem to fix the problem permanently. I've try to create a custom centos 7 box with Packer ( https://atlas.hashicorp.com/sfeirbenelux/boxes/centos7), and I reproduce the issue too.

I suppose that's a Centos 7 specific issue ? Do you already have the same problem ? Is there a way to fix this by adding a vagrant command ?

My environment :

OS X Yosemite ➜ ~ vagrant --version Vagrant 1.7.2 ➜ ~ VBoxManage --version 4.3.26r98988

解决方案

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 ;)

这篇关于具有专用网络的Centos7丢失了固定IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆