Centos7 with a private network lost a fixed IP address

I have a network problem with the centos7 firewall. When I set up a private network with a fixed IP address, this first binds, but gets lost after a few 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 stray 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 to the box, it seems that ip is lost.

 sudo /sbin/ifup eth1 

Fix the problem temporarily, but the IP will be lost again. Rebooting the box (halt & vagrant up stroller) seems to permanently fix the problem. I tried to create a centos 7 custom block with the Packer package ( https://atlas.hashicorp.com/sfeirbenelux/boxes/centos7 ) and I will reproduce this problem too.

I suppose a specific Centos 7 problem? Do you already have the same problem? Is there any way to fix this by adding a roaming team?

My environment:

OS X Yosemite ➜ ~ Tramp - version of Tramp 1.7.2 ➜ ~ VBoxManage - version 4.3.26r98988

+5
source share
3 answers

The problem seems to be due to the DHCP configuration (issue: https://github.com/mitchellh/vagrant/issues/5590 )

the network service does not restart NetworkManager, so it will continue to wait for the lease of dhcp .. and after the dhcp timeout the fixed ip will be deleted.

Adding a shell script using

 sudo nmcli connection reload sudo systemctl restart network.service 

Fix the problem

EDIT: vagrant 1.7.3+ fixes the error too;)

+8
source

Newer versions of Vagrant (1.9.1) seem to have a similar problem.

A migration request that fixes the problem has already been merged (not yet issued):

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

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

  • Locate the local Vagrant installation (on Fedora this is /opt/vagrant/ )
  • Navigate to the strollers gem folder:

     cd embedded/gems/gems/vagrant-1.9.1 
  • Initialize the new Git repository and add the remote GitHub:

     git init git remote add origin https://github.com/mitchellh/vagrant.git git fetch --all 
  • Issue a new branch and reset it to the current version (for example, 1.9.1).

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

     git checkout -b hotfixes git reset --hard v1.9.1 
  • Now apply the fix:

     git cherry-pick 96611341a96d7d19fdade5556a110b22c6add22b 

After that, a vagrant reload should normally open the local network.

+6
source

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

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

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

+6
source

All Articles