systemctl restart network.service命令执行失败

今天拷贝了一个linux虚拟机,要修改虚拟机ip和计算机名。先修改ip地址:

[root@centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736
改了地址之后,重启网络服务,执行命令,报错如下:

Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
[root@centos ~]# systemctl status network.service
● network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network)
   Active: failed (Result: exit-code) since Tue 2019-12-10 22:12:47 PST; 14s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 3828 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
  Process: 4348 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)

Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos systemd[1]: network.service: control process exited,...=1
Dec 10 22:12:47 centos systemd[1]: Failed to start LSB: Bring up/down netwo...g.
Dec 10 22:12:47 centos systemd[1]: Unit network.service entered failed state.
Dec 10 22:12:47 centos systemd[1]: network.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

带上-l参数查看详细错误:
[root@centos ~]# systemctl status network.service -l
● network.service - LSB: Bring up/down networking
   Loaded: loaded (/etc/rc.d/init.d/network)
   Active: failed (Result: exit-code) since Tue 2019-12-10 22:12:47 PST; 52s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 3828 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
  Process: 4348 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)

Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos network[4348]: RTNETLINK answers: File exists
Dec 10 22:12:47 centos systemd[1]: network.service: control process exited, code=exited status=1
Dec 10 22:12:47 centos systemd[1]: Failed to start LSB: Bring up/down networking.
Dec 10 22:12:47 centos systemd[1]: Unit network.service entered failed state.
Dec 10 22:12:47 centos systemd[1]: network.service failed.

重点查了一下这个错误:Failed to start LSB: Bring up/down networking. 原来虚拟机复制之后要修改mac地址,把虚拟机本身的mac地址得修改到ifcfg-eno16777736文件的HWADDR参数中。

查看mac地址:

[root@centos ~]# ip addr
1: lo: 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: eno16777736: mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:6a:73:c4 brd ff:ff:ff:ff:ff:ff
3: virbr0: mtu 1500 qdisc noqueue state DOWN 
    link/ether 52:54:00:26:03:f7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500
    link/ether 52:54:00:26:03:f7 brd ff:ff:ff:ff:ff:ff


  蓝色字体的部分是mac地址,复制到ifcfg-eno16777736文件的HWADDR参数中,如果没有这个参数就新建一个。

[root@centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

systemctl restart network.service命令执行失败_第1张图片

[root@centos ~]# systemctl restart network.service
[root@centos ~]# 
重启正常。

---------------------

今天打开虚拟机,网络突然连不上了,一看上面网卡的设置,里面HWADDR参数没有了,又重新加了一下,然后再启动network服务,结果又报上面的错,network.service - LSB: Bring up/down networking。

后来查看具体日志:journalctl -xe

systemctl restart network.service命令执行失败_第2张图片

 

 

看到日志里写:Bringing up interface eno16777736: Error: Connection activation failed

查了一下说是Netmanager服务和网卡配置不一致引起的,需要把netmanager服务停止了。

解决方法

systemctl stop NetworkManager.service

systemctl disable NetworkManager.service

systemctl restart Network.service

OK,可以连上虚拟机了。

 

 

你可能感兴趣的:(虚拟化)