网络服务不会重新启动

网络服务不会重新启动

我在 Ubuntu 服务器中遇到以下网络问题:

当我尝试重新启动服务网络时,出现以下错误:

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

检查状态时:

# systemctl status networking
* networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
  Drop-In: /run/systemd/generator/networking.service.d
           `-50-insserv.conf-$network.conf
   Active: failed (Result: exit-code) since Mon 2019-08-05 11:49:42 CEST; 4 days ago
     Docs: man:interfaces(5)
  Process: 1789 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 1773 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --exclude=lo)" ] && udevadm settle (code=exited, status=0/SUCCESS)
 Main PID: 1789 (code=exited, status=1/FAILURE)

日志说:

# journalctl -xe
Aug 09 14:12:38 XXXXXXXXXXXXXXXXXXXXXXXXX systemd[1]: Stopped Raise network interfaces.
-- Subject: Unit networking.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit networking.service has finished shutting down.
Aug 09 14:12:38 XXXXXXXXXXXXXXXXXXXXXXXXX systemd[1]: Starting Raise network interfaces...
-- Subject: Unit networking.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit networking.service has begun starting up.
Aug 09 14:12:38 XXXXXXXXXXXXXXXXXXXXXXXXXX ifup[4487]: RTNETLINK answers: File exists
Aug 09 14:12:38 XXXXXXXXXXXXXXXXXXXXXXXXXX ifup[4487]: Failed to bring up ens160.
Aug 09 14:12:38 XXXXXXXXXXXXXXXXXXXXXXXXXX systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Aug 09 14:12:38 XXXXXXXXXXXXXXXXXXXXXXXXXX systemd[1]: Failed to start Raise network interfaces.
-- Subject: Unit networking.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit networking.service has failed.
-- 
-- The result is failed.

这是我的网络配置:

# ip a | grep ens
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    inet 172.20.252.15/24 brd 172.20.252.255 scope global ens160
3: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    inet 192.168.254.51/24 brd 192.168.254.255 scope global ens192

文件:

# cat /var/run/network/ifstate.ens192 
ens192

没关系,但是文件 /var/run/network/ifstate.ens160 是空的,所以:

# cat /var/run/network/ifstate
lo=lo
ens192=ens192

因此命令ifupifdownens160 将不起作用,这是正常的,因为空ifstate.ens160文件。

当然,如果我在里面手动添加 ens160/var/run/network/ifstate.ens160,然后我可以正确重新启动网络服务,但是每次重新启动服务器时都会发生这种情况,所以这不是解决方案。

另外,如果我手动执行:

ip addr flush dev ens160

然后ifupifdown将工作,网络服务也将工作,但重新启动后,原来的情况仍然存在。

我在 SE 中看到过类似的问题,例如这个但这两个答案似乎都不能解决我的问题。

造成此问题的原因是什么?我该如何解决这个问题?

编辑:

NetworkManager 服务也在运行,但它不管理涉及的网络接口:

cat /etc/NetworkManager/NetworkManager.conf 
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=false

即使我停止 NetworkManager 服务,网络服务也不会重新启动。

相关内容