我有一台 Ubuntu 18.04.3 服务器,一段时间后它开始无法正常工作。每隔 10-15 小时,我必须重新启动网络服务才能使出站连接正常工作。
我在服务器上托管了一个网站。一切正常,但一段时间后,与外部网站(paypal、smtp 等)的连接总是失败。错误是无法解析 DNS。因此,我尝试直接从 SSH ping IP 地址,但也失败了。我尝试 dig +trace,但也失败了。所有入站连接(如 SSH、与 Web 服务器的连接等)都有效,但所有出站流量在 10-15 小时后都会失败。我清除了所有 iptables。我没有安装任何防火墙。
要再次拥有出站连接,我必须重新启动服务器或重新启动网络,然后
sudo /etc/init.d/networking restart
才能工作一段时间。
以下是一些输出:
$ cat /etc/network/interfaces
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo ens192
iface lo inet loopback
# The primary network interface
allow-hotplug ens192
iface ens192 inet dhcp
iface ens192 inet6 manual
pre-up sleep 5
up dhclient -6 -nw -v ens192
down dhclient -6 -r -v ens192
iface ens192:1 inet static
address 195.110.124.133
netmask 255.255.255.255
auto ens192:1
$ ifconfig -a
ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 82.165.166.153 netmask 255.255.255.255 broadcast 82.165.166.153
inet6 fe80::250:56ff:fe27:368f prefixlen 64 scopeid 0x20<link>
ether 00:50:56:27:36:8f txqueuelen 1000 (Ethernet)
RX packets 251345 bytes 169997864 (169.9 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 183239 bytes 92107852 (92.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens192:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 195.110.124.133 netmask 255.255.255.255 broadcast 195.110.124.133
ether 00:50:56:27:36:8f txqueuelen 1000 (Ethernet)
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 209410 bytes 383378140 (383.3 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 209410 bytes 383378140 (383.3 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.255.255.1 0.0.0.0 UG 0 0 0 ens192
10.255.255.1 0.0.0.0 255.255.255.255 UH 0 0 0 ens192
$ iptables -L -n -v
Chain INPUT (policy ACCEPT 305K packets, 356M bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 264K packets, 321M bytes)
pkts bytes target prot opt in out source destination
我真的不知道该怎么办。在我看来,一切都还好。
编辑1
我检查了系统日志文件,发现了出站连接停止工作的时刻
Oct 02 05:10:16 localhost dhclient[701]: DHCPREQUEST of 82.165.166.153 on ens192 to 255.255.255.255 port 67 (xid=0x21426427)
Oct 02 05:10:18 localhost systemd[1]: Stopping Network Name Resolution...
Oct 02 05:10:18 localhost systemd[1]: Stopped Network Name Resolution.
Oct 02 05:10:18 localhost systemd[1]: Starting Network Name Resolution...
Oct 02 05:10:18 localhost systemd-resolved[72821]: Positive Trust Anchors:
Oct 02 05:10:18 localhost systemd-resolved[72821]: . IN DS 19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5
Oct 02 05:10:18 localhost systemd-resolved[72821]: . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d
Oct 02 05:10:18 localhost systemd-resolved[72821]: Negative trust anchors: 10.in-addr.arpa 16.172.in-addr.arpa 17.172.in-addr.arpa 18.172.in-addr.arpa 19.172.in-addr.arpa 20.172.in-addr.arpa 21.172.in-addr.arpa 22.172.in-addr.arpa 23.172.in-addr.arpa 24.172.in-addr.arpa 25.172.in-addr.arpa 26.172.in-addr.arpa 27.172.in-addr.arpa 28.172.in-addr.arpa 29.172.in-addr.arpa 30.172.in-addr.arpa 31.172.in-addr.arpa 168.192.in-addr.arpa d.f.ip6.arpa corp home internal intranet lan local private test
Oct 02 05:10:18 localhost systemd-resolved[72821]: Defaulting to hostname 'linux'.
Oct 02 05:10:18 localhost systemd[1]: Started Network Name Resolution.
Oct 02 05:10:18 localhost systemd[1]: Starting resolvconf-pull-resolved.service...
Oct 02 05:10:18 localhost named[979]: no longer listening on 82.165.166.153#53
Oct 02 05:10:18 localhost systemd[1]: Started resolvconf-pull-resolved.service.
Oct 02 05:10:18 localhost dhclient[701]: DHCPDISCOVER on ens192 to 255.255.255.255 port 67 interval 3 (xid=0x420a5400)
Oct 02 05:10:18 localhost dhclient[701]: DHCPREQUEST of 82.165.166.153 on ens192 to 255.255.255.255 port 67 (xid=0x540a42)
Oct 02 05:10:18 localhost dhclient[701]: DHCPOFFER of 82.165.166.153 from 10.255.243.13
Oct 02 05:10:18 localhost dhclient[701]: DHCPACK of 82.165.166.153 from 10.255.243.13
Oct 02 05:10:18 localhost systemd[1]: Reloading Samba SMB Daemon.
Oct 02 05:10:18 localhost systemd[1]: Reloaded Samba SMB Daemon.
Oct 02 05:10:18 localhost named[979]: listening on IPv4 interface ens192, 82.165.166.153#53
Oct 02 05:10:18 localhost systemd[1]: Stopping Network Name Resolution...
Oct 02 05:10:18 localhost systemd[1]: Stopped Network Name Resolution.
Oct 02 05:10:18 localhost systemd[1]: Starting Network Name Resolution...
Oct 02 05:10:18 localhost systemd-resolved[72855]: Positive Trust Anchors:
Oct 02 05:10:18 localhost systemd-resolved[72855]: . IN DS 19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5
Oct 02 05:10:18 localhost systemd-resolved[72855]: . IN DS 20326 8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d
Oct 02 05:10:18 localhost systemd-resolved[72855]: Negative trust anchors: 10.in-addr.arpa 16.172.in-addr.arpa 17.172.in-addr.arpa 18.172.in-addr.arpa 19.172.in-addr.arpa 20.172.in-addr.arpa 21.172.in-addr.arpa 22.172.in-addr.arpa 23.172.in-addr.arpa 24.172.in-addr.arpa 25.172.in-addr.arpa 26.172.in-addr.arpa 27.172.in-addr.arpa 28.172.in-addr.arpa 29.172.in-addr.arpa 30.172.in-addr.arpa 31.172.in-addr.arpa 168.192.in-addr.arpa d.f.ip6.arpa corp home internal intranet lan local private test
Oct 02 05:10:18 localhost systemd-resolved[72855]: Defaulting to hostname 'linux'.
Oct 02 05:10:18 localhost systemd[1]: Started Network Name Resolution.
Oct 02 05:10:18 localhost systemd[1]: Starting resolvconf-pull-resolved.service...
Oct 02 05:10:18 localhost systemd[1]: Started resolvconf-pull-resolved.service.
Oct 02 05:10:18 localhost dhclient[701]: bound to 82.165.166.153 -- renewal in 20130 seconds.
Oct 02 05:10:23 localhost freshclam[929]: Wed Oct 2 05:10:23 2019 -> Received signal: wake up
Oct 02 05:10:23 localhost freshclam[929]: Wed Oct 2 05:10:23 2019 -> ClamAV update process started at Wed Oct 2 05:10:23 2019
Oct 02 05:10:40 localhost plesk_saslauthd[72813]: select timeout, exiting
Oct 02 05:10:48 localhost dhclient[755]: XMT: Solicit on ens192, interval 118130ms.
Oct 02 05:10:48 localhost dhclient[755]: RCV: Advertise message on ens192 from fe80::250:56ff:fea8:c43.
Oct 02 05:10:48 localhost dhclient[755]: RCV: Advertise message on ens192 from fe80::250:56ff:fe8b:e07d.
Oct 02 05:10:55 localhost systemd-resolved[72855]: Using degraded feature set (UDP) for DNS server 8.8.8.8.
为什么网络名称解析正在重新启动?