systemd-network 只能工作很短的时间

systemd-network 只能工作很短的时间

我最近注意到,ping在我的服务器上,该功能只能工作一小段时间。五到十分钟后reboot,我 ping 除我的服务器之外的任何服务器,都会导致 100% 的数据包丢失。

我已经将问题定位到systemd-network服务上。当我重新启动该服务时,它又ping开始工作了……但同样,只持续了很短的时间。我已经设置了调试,我可以知道该服务正在尝试获取某些东西但失败了,但我对网络了解不够,无法理解如何解决它。我认为罪魁祸首是最后几行,当服务发送未得到服务的请求时。我应该如何解决这个问题?

Dec 21 22:39:44 mail systemd[1]: Started Network Service.
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Link state is up-to-date
Dec 21 22:39:44 mail systemd-networkd[698]: net0: found matching network '/run/systemd/network/10-netplan-net0.network'
Dec 21 22:39:44 mail systemd-networkd[698]: net0: IPv6 successfully enabled
Dec 21 22:39:44 mail systemd-networkd[698]: lo: Link is not managed by us
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Setting address genmode for link
Dec 21 22:39:44 mail systemd-networkd[698]: lo: Link state is up-to-date
Dec 21 22:39:44 mail systemd-networkd[698]: Virtualization Bochs found in DMI (/sys/class/dmi/id/bios_vendor)
Dec 21 22:39:44 mail systemd-networkd[698]: Virtualization found, CPUID=KVMKVMKVM
Dec 21 22:39:44 mail systemd-networkd[698]: Found VM virtualization kvm
Dec 21 22:39:44 mail systemd-networkd[698]: lo: Unmanaged
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Setting address genmode done.
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Bringing link up
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Flags change: +UP +LOWER_UP +RUNNING
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Link UP
Dec 21 22:39:44 mail systemd-networkd[698]: LLDP: Started LLDP client
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Started LLDP.
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Gained carrier
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Setting addresses
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Updating address: 123.456.78.910/23 (valid forever)
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Addresses set
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Setting routes
Dec 21 22:39:44 mail systemd-networkd[698]: net0: Routes set
Dec 21 22:39:46 mail systemd-networkd[698]: net0: Adding address: fe80::a0ab:7dff:fe09:4cb1/64 (valid forever)
Dec 21 22:39:46 mail systemd-networkd[698]: net0: Gained IPv6LL
Dec 21 22:39:46 mail systemd-networkd[698]: net0: Configured
Dec 21 22:39:47 mail systemd-networkd[791]: net0: Updating address: 123.456.78.910/23 (valid forever)
Dec 21 22:39:47 mail systemd-networkd[791]: net0: Addresses set
Dec 21 22:39:47 mail systemd-networkd[791]: net0: Setting routes
Dec 21 22:39:47 mail systemd-networkd[791]: net0: Routes set
Dec 21 22:39:47 mail systemd-networkd[791]: net0: Configured
Dec 21 22:39:48 mail systemd-networkd[791]: Got inotify event on bus n/a.
Dec 21 22:39:48 mail systemd-networkd[791]: Added inotify watch for /run on bus n/a: 2
Dec 21 22:39:48 mail systemd-networkd[791]: Added inotify watch for /run/dbus on bus n/a: -1
Dec 21 22:39:48 mail systemd-networkd[791]: Got inotify event on bus n/a.
Dec 21 22:39:48 mail systemd-networkd[791]: Added inotify watch for /run on bus n/a: 2
Dec 21 22:39:48 mail systemd-networkd[791]: Added inotify watch for /run/dbus on bus n/a: -1
Dec 21 22:39:48 mail systemd-networkd[791]: Got inotify event on bus n/a.
Dec 21 22:39:48 mail systemd-networkd[791]: Added inotify watch for /run on bus n/a: 2
Dec 21 22:39:48 mail systemd-networkd[791]: Added inotify watch for /run/dbus on bus n/a: -1
Dec 21 22:39:48 mail systemd-networkd[791]: Got inotify event on bus n/a.
Dec 21 22:39:48 mail systemd-networkd[791]: Added inotify watch for /run on bus n/a: 2
Dec 21 22:39:48 mail systemd-networkd[791]: Added inotify watch for /run/dbus on bus n/a: -1
Dec 21 22:39:48 mail systemd-networkd[791]: Got inotify event on bus n/a.
Dec 21 22:39:48 mail systemd-networkd[791]: Bus n/a: changing state WATCH_BIND → AUTHENTICATING
Dec 21 22:39:48 mail systemd-networkd[791]: Bus n/a: changing state AUTHENTICATING → HELLO
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 signature=n/a error-name=n/a error-message=n/a
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RequestName cookie=2 reply_cookie=0 signature=su error-name=n/a error-message=n/a
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=method_call sender=n/a destination=org.freedesktop.DBus path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=3 reply_cookie=0 signature=s error-name=n/a error-message=n/a
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=4 reply_cookie=0 signature=sa{sv}as error-name=n/a error-mess
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_31 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=5 reply_cookie=0 signature=sa{sv}as error-name=n/a error-mess
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=6 reply_cookie=0 signature=sa{sv}as error-name=n/a error-mess
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=7 reply_cookie=0 signature=sa{sv}as error-name=n/a error-mess
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=8 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_31 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=9 reply_cookie=0 signature=sa{sv}as error-name=n/a error-mess
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=10 reply_cookie=0 signature=sa{sv}as error-name=n/a error-mes
Dec 21 22:39:48 mail systemd-networkd[791]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=11 reply_cookie=0 signature=sa{sv}as error-name=n/a error-mes
Dec 21 22:39:48 mail systemd-networkd[791]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.1 path=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 signature=s error-name=n/a error-message=n/a
Dec 21 22:39:48 mail systemd-networkd[791]: Bus n/a: changing state HELLO → RUNNING
Dec 21 22:39:48 mail systemd-networkd[791]: Got message type=signal sender=org.freedesktop.DBus.Local destination=n/a path=/org/freedesktop/DBus/Local interface=org.freedesktop.DBus.Local member=Connected cookie=4294967295 reply_cookie=0 signature=n/a error-name=n/a erro
Dec 21 22:39:48 mail systemd-networkd[791]: Got message type=signal sender=org.freedesktop.DBus destination=:1.1 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=2 reply_cookie=0 signature=s error-name=n/a error-message=n/a
Dec 21 22:39:48 mail systemd-networkd[791]: Got message type=signal sender=org.freedesktop.DBus destination=:1.1 path=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameAcquired cookie=3 reply_cookie=0 signature=s error-name=n/a error-message=n/a
Dec 21 22:39:48 mail systemd-networkd[791]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.1 path=n/a interface=n/a member=n/a cookie=4 reply_cookie=2 signature=u error-name=n/a error-message=n/a
Dec 21 22:39:48 mail systemd-networkd[791]: Successfully acquired requested service name.
Dec 21 22:39:48 mail systemd-networkd[791]: Got message type=method_return sender=org.freedesktop.DBus destination=:1.1 path=n/a interface=n/a member=n/a cookie=5 reply_cookie=3 signature=n/a error-name=n/a error-message=n/a
Dec 21 22:39:48 mail systemd-networkd[791]: Match type='signal',sender='org.freedesktop.login1',path='/org/freedesktop/login1',interface='org.freedesktop.login1.Manager',member='PrepareForSleep' successfully installed.


Dec 21 22:39:52 mail systemd-networkd[791]: NDISC: Sent Router Solicitation, next solicitation in 8s
Dec 21 22:39:59 mail systemd-networkd[791]: NDISC: No RA received before link confirmation timeout
Dec 21 22:39:59 mail systemd-networkd[791]: NDISC: Invoking callback for 't'.
Dec 21 22:40:00 mail systemd-networkd[791]: NDISC: Sent Router Solicitation, next solicitation in 17s
Dec 21 22:40:17 mail systemd-networkd[791]: NDISC: Sent Router Solicitation, next solicitation in 34s
Dec 21 22:40:52 mail systemd-networkd[791]: NDISC: Sent Router Solicitation, next solicitation in 1min 9s
Dec 21 22:42:01 mail systemd-networkd[791]: NDISC: Sent Router Solicitation, next solicitation in 2min 17s
Dec 21 22:44:19 mail systemd-networkd[791]: NDISC: Sent Router Solicitation, next solicitation in 4min 46s
Dec 21 22:48:26 mail systemd-networkd[791]: NDISC: Received Router Advertisement: flags none preference medium lifetime 1800 sec
Dec 21 22:48:26 mail systemd-networkd[791]: NDISC: Invoking callback for 'r'.
Dec 21 22:48:27 mail systemd-networkd[791]: net0: Updating address: 2a02:e00:ffec:0:a0ab:7dff:fe09:4cb1/64 (valid for 4w 1d 23h 59min 59s)
Dec 21 22:48:28 mail systemd-networkd[791]: net0: Updating address: 2a02:e00:ffec:398:a0ab:7dff:fe09:4cb1/64 (valid for 4w 1d 23h 59min 59s)

我在内核为 4.15.0-200-generic 的 Ubuntu 18.04.6 LTS 上。我认为问题始于内核 4.15.0-197-generic。

输出networkctl

IDX LINK             TYPE               OPERATIONAL SETUP     
  1 lo               loopback           carrier     configured
  2 net0             ether              routable    configured

2 links listed.

编辑1:

tracerouteping工作时的输出:

nicholas@mail:~$ sudo traceroute -T www.google.com
traceroute to www.google.com (172.217.168.228), 30 hops max, 60 byte packets
 1  123.456.78.9 (123.456.78.9)  1.617 ms  1.626 ms  1.681 ms
 2  bg1.dus2.de.as29141.net (5.45.181.211)  1.433 ms  1.434 ms  1.420 ms
 3  bg1.ams1.nl.as29141.net (5.45.181.213)  6.051 ms  6.027 ms  6.048 ms
 4  core1.ams.net.google.com (80.249.208.247)  7.057 ms  7.138 ms  7.121 ms
 5  108.170.241.129 (108.170.241.129)  6.813 ms  6.870 ms  6.750 ms
 6  216.239.49.13 (216.239.49.13)  7.504 ms  6.656 ms 209.85.252.245 (209.85.252.245)  6.520 ms
 7  ams15s40-in-f4.1e100.net (172.217.168.228)  5.840 ms  5.883 ms  5.750 ms

有时,第一行会变为星号:1 * * *

tracerouteping不工作时的输出:

traceroute to www.google.com (142.250.179.164), 30 hops max, 60 byte packets
 1  130.255.76.1 (130.255.76.1)  1.539 ms  1.534 ms *
 2  bg1.dus2.de.as29141.net (5.45.181.211)  1.620 ms  1.638 ms  1.565 ms
 3  bg1.ams1.nl.as29141.net (5.45.181.213)  6.031 ms  6.024 ms  6.020 ms
 4  core1.ams.net.google.com (80.249.208.247)  7.135 ms  7.109 ms  7.114 ms
 5  108.170.241.161 (108.170.241.161)  7.662 ms 108.170.241.129 (108.170.241.129)  7.649 ms 108.170.241.161 (108.170.241.161)  7.430 ms
 6  142.251.48.175 (142.251.48.175)  6.783 ms  5.860 ms 142.251.48.177 (142.251.48.177)  5.898 ms
 7  ams15s41-in-f4.1e100.net (142.250.179.164)  5.892 ms  5.815 ms  5.868 ms

我的/etc/systemd/network/wan.network文件:

[Match]
Name=net0
Type=ether

[Network]
# Use 'yes' instead of 'ipv6' for both ipv4 and ipv6.
DHCP=yes

但是,日志显示:Ignoring /etc/systemd/network/wan.network, because it's not a regular file with suffix .netdev.我不知道这是否相关。

相关内容