Centos 7はpacker / vagrantを使用して予測可能なネットワークインターフェイス名を無効にします。

Centos 7はpacker / vagrantを使用して予測可能なネットワークインターフェイス名を無効にします。

ローカル開発の放浪ボックスをCentOS 7.2(6.8から)にアップグレードしようとしましたが、新しい「予測可能なネットワークインターフェイス名」に問題が発生しました。私の人形構成にはeth0とeth1が必要ですが、enp0s3とenp0s8が必要です。

以下を追加して、キックスタートファイルで予測可能なネットワークインターフェイス名を無効にしました。

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

パッケージ biosdevname を削除します。

私の放浪者ボックスが起動すると、eth0とeth1(ip -aを実行したときに表示されます)が/etc/sysconfig/network-scripts/にネットワークスクリプトがありません(ifcfg-enp0s3とifcfg-loのみ)。 。

vagrantがこの仮想マシンを起動すると、次のエラーが表示されます。

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 は以下を表示します。

-- 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.

eth0とeth1を維持しながら動作させるにはどうすればよいですか?

ありがとう

ベストアンサー1

私はパッケージに設定スクリプトを追加しましたが、問題が解決したようです。

#!/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'

おすすめ記事