systemctl 网络存在实际问题

systemctl 网络存在实际问题

我在尝试重新启动 systemctl 网络时遇到了困难。

我对 Linux 还只是中级水平,但对于 Ubuntu 18.04 中所有带有 netplan 等新功能,我好像什么都不懂。我需要比我更了解这些的人的帮助。

这是我们自己的服务器,运行 Ubuntu 18.04 Server,因此不涉及托管公司。我们托管的网站大部分情况下都可以运行(这里有另一个关于根域无法运行的问题,但 www.domain.com 可以正常运行),但出于某种原因,systemctl 无法正常启动 - 这也包括在启动时。出于安全原因,服务器已加密。

/etc/network/interfaces 的内容

# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
# Generated by debian-installer.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

#source /etc/network/interfaces.d/*

# The loopback network interface
#auto lo
#iface lo inet loopback

# The primary network interface
#auto enp0s10
#iface enp0s10 inet static
    #address 72.31.51.26
    #netmask 255.255.255.248
    #gateway 72.31.51.25
    #dns-nameservers 75.114.81.1 75.114.81.2

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: networkd

这是我收到的错误:

karmacomposer@PANGEAVERSE:/$ sudo 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,结果如下:

karmacomposer@PANGEAVERSE:/$ systemctl status networking
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2018-07-18 12:29:54 EDT; 7min ago
     Docs: man:interfaces(5)
  Process: 11835 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 11821 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --excl
 Main PID: 11835 (code=exited, status=1/FAILURE)

Jul 18 12:29:54 PANGEAVERSE.pangeawerks.com systemd[1]: Starting Raise network interfaces...
Jul 18 12:29:54 PANGEAVERSE.pangeawerks.com sh[11821]: /etc/network/interfaces:22: misplaced option
Jul 18 12:29:54 PANGEAVERSE.pangeawerks.com sh[11821]: ifquery: couldn't read interfaces file "/etc/network/interfaces"
Jul 18 12:29:54 PANGEAVERSE.pangeawerks.com ifup[11835]: /etc/network/interfaces:22: misplaced option
Jul 18 12:29:54 PANGEAVERSE.pangeawerks.com ifup[11835]: /sbin/ifup: couldn't read interfaces file "/etc/network/interfaces"
Jul 18 12:29:54 PANGEAVERSE.pangeawerks.com systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Jul 18 12:29:54 PANGEAVERSE.pangeawerks.com systemd[1]: networking.service: Failed with result 'exit-code'.
Jul 18 12:29:54 PANGEAVERSE.pangeawerks.com systemd[1]: Failed to start Raise network interfaces.

我也尝试以 root 身份执行此操作:

root@PANGEAVERSE:/# systemctl status networking
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2018-07-18 12:29:54 EDT; 36s ago
     Docs: man:interfaces(5)
  Process: 11835 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
  Process: 11821 ExecStartPre=/bin/sh -c [ "$CONFIGURE_INTERFACES" != "no" ] && [ -n "$(ifquery --read-environment --list --excl
 Main PID: 11835 (code=exited, status=1/FAILURE)

以下是01-systemd-networkd-eth.yaml 的内容:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
 version: 2
 renderer: networkd
 ethernets:
   enp0s10:
     dhcp4: no
     dhcp6: no
     addresses: [72.31.51.26/24, '2001:1::2/64']
     gateway4: 72.31.51.25
     nameservers:
       addresses: [75.114.81.1,75.114.81.2]
       search: [ www.pangeawerks.com ]

以下是文件 01-network-manager-all.yaml 的内容

network:
  version: 2
  renderer: networkd

我刚刚将网络渲染器更改为 networkd - 它被设置为 NetworkManager,在我看来这是错误的 - 因为我们使用的是 Ubuntu 18.04 Server,而不是使用 GUI 来配置东西。

我已经花了 72 小时独自尝试解决这个问题(这个问题和上面提到的其他 DNS 问题),但我已经束手无策了。无论搜索多少次,尝试多少次,都没有用。现在我只能寻求帮助了。

我希望有人能帮助我 - 我将不胜感激。

麦克风

答案1

Please uncomment the loopback network interface lines in your /etc/network
/interfaces file and then try again to restart the networking service –  
steeldriver 32 mins ago

问题解决了!非常感谢。

麦克风

相关内容