"private_network" not configuring running network on Centos 7

1,237 views
Skip to first unread message

Matthew Pounsett

unread,
Dec 8, 2016, 7:23:22 PM12/8/16
to Vagrant

I've got a locally built base box which is built on the official centos/7 box from Atlas.  The only change at this point is that I've added the Virtualbox Guest Additions to it.   

When I build a host based on it, vagrant is able to write the boot config for a host-only network, but isn't configuring the running network on the host.   

This is my Vagrantfile
Vagrant.configure("2") do |config|
    config.vm.define "host01" do |host|
        host.vm.box = "centos7"
        host.vm.box_url = "file://~/src/vagrant/centos7.json"
        host.vm.network "private_network", ip: "192.168.56.11"
    end
end

I'm using config.vm.define because this will eventually be building multiple hosts.

When I run `vagrant up` I get this output:
Bringing machine 'host01' up with 'virtualbox' provider...
==> host01: Importing base box 'centos7'...
==> host01: Matching MAC address for NAT networking...
==> host01: Checking if box 'centos7' is up to date...
==> host01: Setting the name of the VM: Vagrant_host01_1481242515497_92317
==> host01: Clearing any previously set network interfaces...
==> host01: Preparing network interfaces based on configuration...
    host01: Adapter 1: nat
    host01: Adapter 2: hostonly
==> host01: Forwarding ports...
    host01: 22 (guest) => 2222 (host) (adapter 1)
==> host01: Booting VM...
==> host01: Waiting for machine to boot. This may take a few minutes...
    host01: SSH address: 127.0.0.1:2222
    host01: SSH username: vagrant
    host01: SSH auth method: private key
    host01: Warning: Remote connection disconnect. Retrying...
    host01: 
    host01: Vagrant insecure key detected. Vagrant will automatically replace
    host01: this with a newly generated keypair for better security.
    host01: 
    host01: Inserting generated public key within guest...
    host01: Removing insecure key from the guest if it's present...
    host01: Key inserted! Disconnecting and reconnecting using new SSH key...
==> host01: Machine booted and ready!
==> host01: Checking for guest additions in VM...
==> host01: Configuring and enabling network interfaces...
==> host01: Mounting shared folders...
    host01: /vagrant => /Users/matthewpounsett/Development/tld-infrastructure/Vagrant


And here's what I find on the VM:
$ vagrant ssh
[vagrant@localhost ~]$ ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:d8:71:80 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
       valid_lft 86396sec preferred_lft 86396sec
    inet6 fe80::5054:ff:fed8:7180/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 08:00:27:60:7d:5c brd ff:ff:ff:ff:ff:ff
[vagrant@localhost ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth1 
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.56.11
NETMASK=255.255.255.0
DEVICE=eth1
PEERDNS=no
#VAGRANT-END
[vagrant@localhost ~]$ logout
Connection to 127.0.0.1 closed.


I've based what I'm doing off the docs at <https://www.vagrantup.com/docs/networking/private_network.html>.  What am I missing here?  

Alvaro Miranda Aguilera

unread,
Dec 10, 2016, 3:11:46 PM12/10/16
to vagra...@googlegroups.com

On Fri, Dec 9, 2016 at 1:23 AM, Matthew Pounsett <ma...@conundrum.com> wrote:
Vagrant.configure("2") do |config|
    config.vm.define "host01" do |host|
        host.vm.box = "centos7"
        host.vm.box_url = "file://~/src/vagrant/centos7.json"
        host.vm.network "private_network", ip: "192.168.56.11"
    end
end

hello

Vagrant version?
host os?

Can you share a gist to the output of

VAGRANT_LOG=debug
vagrant up
?



--
Alvaro

Alvaro Miranda Aguilera

unread,
Dec 10, 2016, 3:26:17 PM12/10/16
to Vagrant

Hello

I did start one with centos/7 and I can see this:

 INFO ssh: Execute: # Down the interface before munging the config file. This might

# fail if the interface is not actually set up yet so ignore

# errors.

/sbin/ifdown 'eth1'

# Move new config into place

mv -f '/tmp/vagrant-network-entry-eth1-1481401319-0' '/etc/sysconfig/network-scripts/ifcfg-eth1'

# attempt to force network manager to reload configurations

nmcli c reload || true


# Restart network (through NetworkManager if running)

if service NetworkManager status 2>&1 | grep -q running; then

  service NetworkManager restart

else

  service network restart

fi

 (sudo=true)

DEBUG ssh: stderr: Redirecting to /bin/systemctl restart  NetworkManager.service



So, seems being worked by this:


https://github.com/mitchellh/vagrant/issues/8096


Alvaro

Matthew Pounsett

unread,
Dec 10, 2016, 4:27:22 PM12/10/16
to Vagrant


On Saturday, 10 December 2016 15:11:46 UTC-5, Alvaro Miranda Aguilera wrote:

Vagrant version?
host os?

Hmm... Yeah, sorry.  Not sure why I didn't paste those in to the original email.
I'm using Vagrant 1.9.1 on MacOS 10.10.5
 

Can you share a gist to the output of

VAGRANT_LOG=debug
vagrant up

absolutely.

It looks to me like the bug you noted in your other post... should be fixed in 1.9.2.
I have been using a reboot at the end of my provisioning script as a workaround.   That should be fine until the patch makes it out into the MacOS distribution.

Thanks!

Alvaro Miranda Aguilera

unread,
Dec 11, 2016, 11:32:47 AM12/11/16
to vagra...@googlegroups.com
no need for that.

just add  in the meantime

config.vm.provision "shell", inline: "ifup eth1", run: "always"

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/29b48573-c01a-452e-98e9-b3848cbcb13b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Mark H.

unread,
Dec 11, 2016, 8:13:05 PM12/11/16
to Vagrant


On Sunday, December 11, 2016 at 9:32:47 AM UTC-7, Alvaro Miranda Aguilera wrote:
no need for that.

just add  in the meantime

config.vm.provision "shell", inline: "ifup eth1", run: "always"
On Sat, Dec 10, 2016 at 10:27 PM, Matthew Pounsett <ma...@conundrum.com> wrote:


On Saturday, 10 December 2016 15:11:46 UTC-5, Alvaro Miranda Aguilera wrote:

Vagrant version?
host os?

Hmm... Yeah, sorry.  Not sure why I didn't paste those in to the original email.
I'm using Vagrant 1.9.1 on MacOS 10.10.5
 

Can you share a gist to the output of

VAGRANT_LOG=debug
vagrant up

absolutely.

It looks to me like the bug you noted in your other post... should be fixed in 1.9.2.
I have been using a reboot at the end of my provisioning script as a workaround.   That should be fine until the patch makes it out into the MacOS distribution.

Thanks!

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro


I'm having the same issue. Glad it's not just me. I just started reading Jeff Geerlings Ansible book and am new to Vagrant and Ansible, so I figured it was my inexperience that was the problem. In my case enp0s8 is created but is not up. If I do it with a ubuntu/trusty64 box it works fine.

Thanks,
Mark

[root@localhost ansible3]# cat Vagrantfile

Vagrant.configure("2") do |config|

  config.vm.box = "geerlingguy/centos7"
  config.vm.network "private_network", ip: "192.168.60.4"

end
[root@localhost ansible3]# vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'geerlingguy/centos7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'geerlingguy/centos7' is up to date...
==> default: Setting the name of the VM: ansible3_default_1481503419064_90554
==> default: Fixed port collision for 22 => 2222. Now on port 2202.
==> 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 (guest) => 2202 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2202
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. 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 it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /home/ansible3
[root@localhost ansible3]# vagrant ssh
[vagrant@localhost ~]$ ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:d0:79:66 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 86375sec preferred_lft 86375sec
    inet6 fe80::a00:27ff:fed0:7966/64 scope link
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 08:00:27:ec:c9:f1 brd ff:ff:ff:ff:ff:ff
[vagrant@localhost ~]$
[vagrant@localhost network-scripts]$ more ifcfg-enp0s8
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.60.4
NETMASK=255.255.255.0
DEVICE=enp0s8
PEERDNS=no
#VAGRANT-END
[vagrant@localhost network-scripts]$


 

Alvaro Miranda Aguilera

unread,
Dec 12, 2016, 5:29:25 AM12/12/16
to vagra...@googlegroups.com
try

Vagrant.configure("2") do |config|
  config.vm.box = "geerlingguy/centos7"
  config.vm.network "private_network", ip: "192.168.60.4"
  #workaround
  config.vm.provision "shell", inline: "ifup enp0s8", run: "always"
end


Will Seaford

unread,
Dec 12, 2016, 11:12:13 AM12/12/16
to Vagrant
I have just had this problem myself and found the latest version was messing it up for me. By changing from 1.9.1 to 1.8.6. This solved my problem. 

Mark H.

unread,
Dec 12, 2016, 11:37:02 PM12/12/16
to Vagrant


On Monday, December 12, 2016 at 9:12:13 AM UTC-7, Will Seaford wrote:
I have just had this problem myself and found the latest version was messing it up for me. By changing from 1.9.1 to 1.8.6. This solved my problem. 


Already running vagrant 1.9.1 on a CentOS 7 host:

[root@localhost ansible3]# vagrant --version
Vagrant 1.9.1
[root@localhost ansible3]# cat /etc/red*
CentOS Linux release 7.2.1511 (Core)

The good news is that Alvaro's workaround worked! Thank you!!!

3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:18:44:89 brd ff:ff:ff:ff:ff:ff
    inet 192.168.60.4/24 brd 192.168.60.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe18:4489/64 scope link
       valid_lft forever preferred_lft forever


 

Alvaro Miranda Aguilera

unread,
Dec 14, 2016, 4:56:14 AM12/14/16
to vagra...@googlegroups.com
Hello.

This is a important issue, and Vagrant developers are working on it.

You can monitor this isse:

Thanks
Alvaro.



--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/119f5af0-a81d-4657-9cad-616f65c2a269%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages