Ubuntu 19.04 中的 DNS 问题

Ubuntu 19.04 中的 DNS 问题

我最近将我的笔记本电脑升级到 19.04(以前是 18.04),从那时起我遇到了 DNS 解析问题。

解析任何地址需要整整 15 秒。例如,这是命令“ping www.google.ch”的 wireshark 跟踪,显示了 DNS 解析中的不稳定行为(抱歉粘贴了一个日志 blob):

  1 0.000000000    127.0.0.1             127.0.0.53            DNS      82     Standard query 0x9885 A google.ch OPT
  2 0.000040848    127.0.0.1             127.0.0.53            DNS      82     Standard query 0xf398 AAAA google.ch OPT
  3 0.000472315    192.168.1.61          192.168.1.1           DNS      71     Standard query 0xbc08 A google.ch
  4 0.000751989    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
  5 0.003821221    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
  6 0.004064023    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
  7 0.005267971    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
  8 0.005497112    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
  9 0.006644819    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 10 0.006863866    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 11 0.007920878    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 12 0.008130719    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 13 0.009242334    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 14 0.009637573    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 15 0.010792517    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 16 0.011031800    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 17 0.012258637    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 18 0.012489432    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 19 0.013713170    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 20 0.013915614    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 21 0.014032986    192.168.1.1           192.168.1.61          DNS      87     Standard query response 0xbc08 A google.ch A 172.217.168.35
 22 0.014322592    127.0.0.53            127.0.0.1             DNS      98     Standard query response 0x9885 A google.ch A 172.217.168.35 OPT
 23 0.015102484    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 24 0.015277122    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 25 0.016431079    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 26 0.016609622    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 27 0.017757978    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 28 0.017919223    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 29 0.018984296    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 30 0.019164206    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 31 0.020291847    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 32 0.020465090    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 33 0.021606042    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 34 0.021834229    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 35 0.022902638    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 36 0.023076859    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 37 0.024185348    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 38 0.024369468    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 39 0.025402235    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 40 0.025557918    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 41 0.026557335    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 42 0.026681040    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 43 0.027705800    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 44 0.027808876    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 45 0.028793187    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 46 0.028893739    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 47 0.029878670    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 48 0.029986119    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 49 0.031010405    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 50 0.031127410    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 51 0.032151807    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 52 0.032261394    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x335e AAAA google.ch
 53 0.033290733    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x335e Refused AAAA google.ch
 54 5.001947117    127.0.0.1             127.0.0.53            DNS      82     Standard query 0x9885 A google.ch OPT
 55 5.002322889    127.0.0.53            127.0.0.1             DNS      98     Standard query response 0x9885 A google.ch A 172.217.168.35 OPT
 56 5.002450775    127.0.0.1             127.0.0.53            DNS      82     Standard query 0xf398 AAAA google.ch OPT
 57 5.002829396    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 58 5.005749595    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 59 5.006000720    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 60 5.007085084    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 61 5.007278137    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 62 5.008493792    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 63 5.008726953    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 64 5.009760440    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 65 5.009962097    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 66 5.011064276    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 67 5.011294755    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 68 5.012464702    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 69 5.012696487    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 70 5.013803847    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 71 5.013991838    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 72 5.015081146    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 73 5.015311695    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 74 5.016397601    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 75 5.016572805    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 76 5.018326688    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 77 5.018522763    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 78 5.019673004    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 79 5.019905288    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 80 5.020942721    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 81 5.021117750    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 82 5.022175880    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 83 5.022368879    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 84 5.023497195    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 85 5.023727693    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 86 5.024716756    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 87 5.024917772    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 88 5.025940891    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 89 5.026242405    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 90 5.027396468    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 91 5.027627309    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 92 5.028669617    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 93 5.028844156    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 94 5.029909396    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 95 5.030099489    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 96 5.031241631    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 97 5.031470878    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
 98 5.032507283    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
 99 5.032684260    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
100 5.033712152    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
101 5.033923324    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
102 5.035076891    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
103 5.035307433    192.168.1.61          192.168.1.1           DNS      71     Standard query 0x897a AAAA google.ch
104 5.036458185    192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x897a Refused AAAA google.ch
105 10.005946641   127.0.0.1             127.0.0.53            DNS      82     Standard query 0x9885 A google.ch OPT
106 10.006376461   127.0.0.53            127.0.0.1             DNS      98     Standard query response 0x9885 A google.ch A 172.217.168.35 OPT
107 10.006552675   127.0.0.1             127.0.0.53            DNS      82     Standard query 0xf398 AAAA google.ch OPT
108 10.006923636   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
109 10.009568741   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
110 10.009795245   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
111 10.010954209   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
112 10.011184364   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
113 10.012458263   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
114 10.012691547   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
115 10.013805929   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
116 10.014036944   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
117 10.015165110   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
118 10.015403914   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
119 10.016501372   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
120 10.016710396   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
121 10.017809472   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
122 10.017988063   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
123 10.019114116   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
124 10.019353925   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
125 10.020505187   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
126 10.020741642   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
127 10.021814158   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
128 10.022045574   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
129 10.023153608   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
130 10.023336649   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
131 10.024412807   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
132 10.024632391   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
133 10.025813396   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
134 10.026244008   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
135 10.027357668   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
136 10.027535923   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
137 10.028599634   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
138 10.028776517   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
139 10.029782946   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
140 10.029961443   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
141 10.031008052   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
142 10.031186821   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
143 10.032214660   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
144 10.032393053   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
145 10.033518425   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
146 10.033744680   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
147 10.034887325   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
148 10.035116833   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
149 10.036226120   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
150 10.036458904   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
151 10.037515996   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
152 10.037775347   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
153 10.038839704   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
154 10.039017849   192.168.1.61          192.168.1.1           DNS      71     Standard query 0x2b09 AAAA google.ch
155 10.040061077   192.168.1.1           192.168.1.61          DNS      71     Standard query response 0x2b09 Refused AAAA google.ch
156 15.024825964   127.0.0.1             127.0.0.53            DNS      100    Standard query 0xb4e4 PTR 35.168.217.172.in-addr.arpa OPT
157 15.025320672   192.168.1.61          192.168.1.1           DNS      89     Standard query 0x0774 PTR 35.168.217.172.in-addr.arpa
158 15.038823507   192.168.1.1           192.168.1.61          DNS      127    Standard query response 0x0774 PTR 35.168.217.172.in-addr.arpa PTR zrh04s14-in-f3.1e100.net
159 15.039215285   127.0.0.53            127.0.0.1             DNS      138    Standard query response 0xb4e4 PTR 35.168.217.172.in-addr.arpa PTR zrh04s14-in-f3.1e100.net OPT

当 PTR 查询完成时(在数据包编号 156 附近),ping 会被阻止整整 15 秒,尽管在数据包 21、55 和 106 处收到了 3 次 A 记录。

这种情况仅当我在工作时使用完全不支持 ipv6 的 wifi 时才会发生。在家里我使用 ipv6,完全没有问题。在有问题的网络的 wifi 设置中,我已禁用 ipv6(gnome 设置),但这对此行为没有影响。

Systemd 解析的配置是默认的:

$ cat /etc/systemd/resolved.conf
...
[Resolve]
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=yes
#DNSStubListener=yes
#ReadEtcHosts=yes


根据@heynnema 的要求进行编辑

$ ls -al /etc/resolv.conf 
lrwxrwxrwx 1 root root 39 Aug 17  2018 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0
search media.int Home
$ dpkg -l *dnsmasq*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name             Version       Architecture Description
+++-================-=============-============-============================================
un  dnsmasq          <none>        <none>       (no description available)
ii  dnsmasq-base     2.80-1ubuntu1 amd64        Small caching DNS proxy and DHCP/TFTP server
un  dnsmasq-base-lua <none>        <none>       (no description available)

$ cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

$ systemd-resolve --status
Global
       LLMNR setting: no
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.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
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 10 (docker0)
      Current Scopes: none
DefaultRoute setting: no
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 9 (vethKHVDZJ)
      Current Scopes: none
DefaultRoute setting: no
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 7 (lxdbr0)
      Current Scopes: none
DefaultRoute setting: no
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 6 (virbr0-nic)
      Current Scopes: none
DefaultRoute setting: no
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 5 (virbr0)
      Current Scopes: none
DefaultRoute setting: no
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 4 (enx4865ee119deb)
      Current Scopes: none
DefaultRoute setting: no
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

Link 3 (wlp2s0)
      Current Scopes: DNS
DefaultRoute setting: yes
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
  Current DNS Server: 192.168.1.1
         DNS Servers: 192.168.1.1
          DNS Domain: ~.
                      Home

Link 2 (enp0s31f6)
      Current Scopes: DNS
DefaultRoute setting: yes
       LLMNR setting: yes
MulticastDNS setting: no
  DNSOverTLS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
  Current DNS Server: 10.136.8.10
         DNS Servers: 10.136.8.10
                      10.137.24.10
          DNS Domain: media.int

作为奖励,以下是我的路线:

$ ip r
default via 192.168.1.1 dev wlp2s0 proto dhcp metric 600 
10.0.0.0/8 via 10.168.38.1 dev enp0s31f6 proto static metric 10 
10.168.38.0/24 dev enp0s31f6 proto kernel scope link src 10.168.38.154 metric 100 
169.254.0.0/16 dev virbr0 scope link metric 1000 linkdown 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown 
192.168.1.0/24 dev wlp2s0 proto kernel scope link src 192.168.1.61 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown 
192.168.224.0/24 dev lxdbr0 proto kernel scope link src 192.168.224.1 

新编辑:

手动编辑/etc/resolv.conf并使用返回的任何 DNS 服务器都resolvectl status可以解决我的问题。

systemd-resolved仅当用作解析器时才会出现此问题,我尝试使用每个可能的值更改选项 DNSSEC。问题仍然存在。

所以我最终编写了一个脚本作为解决方法:

$ cat bin/fix-dns.sh
#!/bin/bash
sudo sed -i '/^nameserver/ s/127.0.0.53/10.136.8.10/' /etc/resolv.conf


我该怎么做才能改变这种情况?为什么解析器如此坚持使用 ipv6,为什么它要等待 PTR 记录才向客户端提供答案?

在此先感谢您的帮助。

答案1

来自评论...

的符号链接/etc/resolv.conf被设置为/run/systemd/resolve/stub-resolv.conf包含options edns0。某些网络不响应此 DNS 扩展,并且 DNS 解析中断。

我们用以下命令重置符号链接:

sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

这可能也会有效:

sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf

附注:

您可能还遇到的一个问题是 DSL 连接的 MTU 设置。

Ubuntu 的网络配置中有一个 MTU 设置,而路由器中有一个 WAN MTU 设置。

对于 DSL,常见的 MTU 设置是 1492。请先尝试此值,然后查看您的网站现在是否可以访问。

要确定正确的设置,请从所有 MTU 设置 = 1500 和 VPN = 关闭开始。(VPN 需要不同的测试)。

在终端:

ping [-c count] [-M do] [-s packet_size] [host]

使用的选项是:

  • c count:ping 次数
  • M hint:选择路径 MTU 发现策略。可以是do(禁止碎片,即使是本地碎片),want(进行 PMTU 发现,当数据包大小较大时在本地进行碎片),或dont(不设置 DF 标志)。
  • s packet_size:指定要发送的数据字节数。

您应该始终从 1472 开始,然后每次减少 10。一旦收到回复,就增加 1,直到收到碎片数据包。取该值(最后一个好值)并将 28 添加到该值以考虑各种 TCP/IP 标头。例如,假设 1452 是合适的数据包大小(您第一次收到对 ping 的 ICMP 回复)。实际的 MTU 大小将是 1480,这是我们正在使用的网络的最佳值。

ping -c 4 -M do -s 1472 8.8.8.8 # this will probably show fragmentation

ping -c 4 -M do -s 1462 8.8.8.8 # may show fragmentation

ping -c 4 -M do -s 1452 8.8.8.8 # no fragmentation?

ping -c 4 -M do -s 1453 8.8.8.8 # still no fragmentation?

参考:如何使用 ICMP ping 确定适当的 MTU 大小

相关内容