在运行“/etc/init.d/network restart”命令时,出现错误“Job for network.service failed. See ‘systemctl status network.service‘ and ‘journalctl -xn‘ for deta”,运行“cat /var/log/messages | grep network”命令查看日志中出现的与network相关的信息,会发现下面输出语句:
Nov 17 11:31:16 openstack network: Bringing up interface eth0: Error: no device found for connection ‘eth0‘.
Nov 17 11:31:16 openstack network: [FAILED]
Nov 17 11:31:16 openstack network: RTNETLINK answers: File exists
Nov 17 11:31:16 openstack network: RTNETLINK answers: File exists
Nov 17 11:31:16 openstack network: RTNETLINK answers: File exists
Nov 17 11:31:16 openstack network: RTNETLINK answers: File exists
Nov 17 11:31:16 openstack network: RTNETLINK answers: File exists
Nov 17 11:31:16 openstack network: RTNETLINK answers: File exists
Nov 17 11:31:16 openstack network: RTNETLINK answers: File exists
Nov 17 11:31:16 openstack network: RTNETLINK answers: File exists
Nov 17 11:31:16 openstack network: RTNETLINK answers: File exists
Nov 17 11:31:16 openstack systemd: network.service: control process exited, code=exited status=1
Nov 17 11:31:16 openstack systemd: Failed to start LSB: Bring up/down networking.
Nov 17 11:31:16 openstack systemd: Unit network.service entered failed state.
解决方法:
打开查看/etc/sysconfig/network-scripts/ifcfg-eth0文件
1. 发现其中的MAC地址和ifconfig命令输出的MAC地址不一样,对于这种情况删除HWADDR这一行或者将这一行更新为ifconfig命令输出的MAC即可。
2. 完成第一步大部分人问题都能解决,如果还是报错的话,仔细看看该文件内有没有DEVICE这一行,如果有要注释或者删掉,因为这跟MAC地址一样也是失效的。
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# HWADDR=1A:E9:47:A5:75:C8
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPADDR=192.168.1.79
PREFIX=24
GATEWAY=192.168.1.1
DNS1=192.168.1.1
DNS2=8.8.8.8
NAME=eth0
UUID=ba670f0c-201a-483b-8379-c8c72c03ab27
# DEVICE=en01677736
ONBOOT=yes