3

I'm trying to upgrade our local dev vagrant box to CentOS 7.2 (from 6.8), but ran into a problem with the new "predictable network interface names". My puppet config is expecting eth0 and eth1, but it's getting enp0s3 and enp0s8.

I managed to disable predictable network interface names in the kickstart file by adding:

bootloader --location=mbr --append="net.ifnames=0"

and removing the package biosdevname

Now when my vagrant box boots it has eth0 and eth1 (shown when I do an ip -a), but I don't have the network scripts in /etc/sysconfig/network-scripts/ (only ifcfg-enp0s3 and ifcfg-lo).

When vagrant boots this VM it shows this error:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

# Update sysconfig
sed -i 's/\(HOSTNAME=\).*/\1vm.example.com/' /etc/sysconfig/network

# Update DNS
sed -i 's/\(DHCP_HOSTNAME=\).*/\1"vm"/' /etc/sysconfig/network-scripts/ifcfg-*

# Set the hostname - use hostnamectl if available
echo 'vm.example.com' > /etc/hostname
if command -v hostnamectl; then
  hostnamectl set-hostname --static 'vm.example.com'
  hostnamectl set-hostname --transient 'vm.example.com'
else
  hostname -F /etc/hostname
fi

# Remove comments and blank lines from /etc/hosts
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts

# Prepend ourselves to /etc/hosts
grep -w 'vm.example.com' /etc/hosts || {
  sed -i'' '1i 127.0.0.1\tvm.example.com\tvm' /etc/hosts
}

# Restart network
service network restart


Stdout from the command:

/bin/hostnamectl
Restarting network (via systemctl):  [FAILED]


Stderr from the command:

Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.

journalctl -xe shows:

-- Unit network.service has begun starting up.
Oct 11 04:28:59 vm.example.com network[3130]: Bringing up loopback interface:  Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 11 04:28:59 vm.example.com network[3130]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 11 04:28:59 vm.example.com network[3130]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 11 04:28:59 vm.example.com network[3130]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-lo'
Oct 11 04:28:59 vm.example.com network[3130]: [  OK  ]
Oct 11 04:28:59 vm.example.com network[3130]: Bringing up interface enp0s3:  Error: Connection activation failed: No suitable device found for this connection.
Oct 11 04:28:59 vm.example.com network[3130]: [FAILED]
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com network[3130]: RTNETLINK answers: File exists
Oct 11 04:28:59 vm.example.com systemd[1]: network.service: control process exited, code=exited status=1
Oct 11 04:28:59 vm.example.com systemd[1]: Failed to start LSB: Bring up/down networking.

How can I keep eth0 and eth1, but make this work correctly?

Thanks

2
  • You also have to install the system with biosdevname=0 set on the kernel command line, and since someone else installed the system, you can't do this. Either build your own Vagrant box or (preferably) fix the puppet configuration. Commented Oct 11, 2016 at 5:17
  • I am using my own vagrant box that I installed myself.
    – Noodles
    Commented Oct 11, 2016 at 5:38

2 Answers 2

1

I added a provisioner script in packer that seems to have fixed this problem:

#!/bin/bash

mv /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i -e 's/enp0s3/eth0/' /etc/sysconfig/network-scripts/ifcfg-eth0
bash -c 'echo NM_CONTROLLED=\"no\" >> /etc/sysconfig/network-scripts/ifcfg-eth0'
0

How can I keep eth0 and eth1, but make this work correctly?

I believe I can help answer the first part about keeping eth0 and eth1 (or at least get you a good reference). According to Consistent Network Device Naming in Linux, you are supposed to be able to disable the new naming with the following from Section 9 of the manual:

Disable during install time

To disable the use of the new naming scheme, during installation (attended or automated), pass the kernel command line parameter biosdevname=0 on the boot command line. The parameter should be passed on the boot command line after installation to ensure that a new network adapter plugged in post installation has a traditional "eth" name.

Its been my experience its hit-or-miss whether it actually works. See, for example, Network device naming problems and aliases for p2p1 and p3p1 back to eth0 and eth1 on Super User.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .