hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.17k stars 4.43k forks source link

RHEL 7 Networking Issues #4345

Closed kylegoch closed 10 years ago

kylegoch commented 10 years ago

This issue is similar to #1997 .

I built a RHEL7 box and wanted to add private networking by assigning and IP address in the Vagrantfile.

I was getting the classic:

ERROR    : [/etc/sysconfig/network-scripts/ifup-eth] Device eth1 does not seem to be present, delaying initialization.

But I noticed when I did the following there was no eth1:

[root@gluster1 network-scripts]# ip addr
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:b0:d6:b2 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 84982sec preferred_lft 84982sec
    inet6 fe80::a00:27ff:feb0:d6b2/64 scope link 
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:bb:3e:42 brd ff:ff:ff:ff:ff:ff

So I went to /etc/sysconfig/network-scripts and noticed there was

ifcfg-enp0s3
ifcfg-eth1
ifcfg-lo

So I got creative and renamed ifcfg-eth1 to ifcfg-enp0s8 (from the ip output above). I also went into the newly renamed file and changed DEVICE=eth1 to DEVICE=enp0s8 then ran ./ifup-eth enp0s8.

And now the output of ip addr matched the config that I would expect it to have. And the extra NIC worked just as expected.

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:b0:d6:b2 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 83959sec preferred_lft 83959sec
    inet6 fe80::a00:27ff:feb0:d6b2/64 scope link 
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:bb:3e:42 brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.11/24 brd 10.10.10.255 scope global enp0s8
       valid_lft forever preferred_lft forever

Im new to RHEL, but not to Vagrant. So I am not sure if this was an issue with my RHEL build, which was built using Opscode Bento's Packer Template, or something that has cropped up in Vagrant.

My Vagrant version is 1.6.3.

Doing a vagrant reload still fails with the above error. But the workaround stays in place. But Vagrant wont do any provisioning for me because its upset of over the networking.

If I comment this line from my Vagrant file

gluster1.vm.network :private_network, ip: "10.10.10.11"

Then vagrant up runs through everything as expected. Except my boxes dont have static IPs.

I will gladly provide whatever extra info is needed, just let me know.

kylegoch commented 10 years ago

Brief update to this. I had to switch over to RHEL 6.5 due to something external to vagrant, and the 6.5 Vagrant Boxes are coming up just fine with the same Vagrantfile from before, just pointing at the 6.5 box.

spkane commented 10 years ago

It appears that Vagrant is not very networkd savy and is possibly also having some issues with it's device naming standard. I have seen evidence of vagrant trying to create files for eth1, but then see a ens33 device in ifconfig.

If I don't set a hostname and I also disable auto_config like this:

config.vm.network :private_network, type: :static, auto_config: false, ip: "192.168.80.10", netmask: "255.255.255.0"

Then I can sort of work around this problem (since vagrant won't restart the network and it is actually working), however if I restart networking, it will generate the same error.

I'm guessing this has something to do with the networkd device naming, it's use of unit files for config, and vagrant using direct commands and the older style network config files to manipulate the network.

courtney-miles commented 10 years ago

I'm having the same issue with a recent build of Gentoo produced using the Veewee definition provided at https://github.com/hyamamoto/gentoo-bento

For me, the workaround suggested by spkane didn't work--it didn't set a static IP. But networking did work. It still creates /etc/init.d/net.eth1, and as spkane said, it errors if you try to restart it manually.

andytson commented 10 years ago

This is caused by the bug referenced at #4171, with a fix at #4195 (the RHEL issue, not the Gentoo)

mitchellh commented 10 years ago

Fixed, see #4195 for more info.