在運行「/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相關的信息,會發現下面輸出語句:spa
Nov 17 11:31:16 openstack network: Bringing up interface eth0: Error: no device found for connection 'eth0'.rest
Nov 17 11:31:16 openstack network: [FAILED]日誌
Nov 17 11:31:16 openstack network: RTNETLINK answers: File existscode
Nov 17 11:31:16 openstack network: RTNETLINK answers: File existsip
Nov 17 11:31:16 openstack network: RTNETLINK answers: File existsit
Nov 17 11:31:16 openstack network: RTNETLINK answers: File existsio
Nov 17 11:31:16 openstack network: RTNETLINK answers: File existsast
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.
從錯誤提示「Error: no device found for connection 'eth0'」能夠肯定是配置文件eth0的問題,打開查看/etc/sysconfig/network-scripts/ifcfg-eth0文件發現其中的MAC地址和ifconfig命令輸出的MAC地址不同,具體以下所示:
[root@openstack ~]# 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
ONBOOT=yes
[root@openstack ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.79 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::8081:a6ff:fe9d:5887 prefixlen 64 scopeid 0x20<link>
ether 82:81:a6:9d:58:87 txqueuelen 1000 (Ethernet)
RX packets 3426 bytes 394042 (384.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 57 bytes 9578 (9.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
因此只需將ifcfg-eth0中的HWADDR變量值改成ifconfig命令裏顯示的MAC地址便可。