在最近升级后的 20.04 上,我无法清除 DNS 缓存

Sam*_*ore 5 dns resolv.conf 20.04

我最近更改了一个网站的 NS 记录,当我使用https://toolbox.googleapps.com/apps/dig/#NS/等在线工具挖掘该记录时,我可以看到它指向正确的位置。即使我的手机在同一个 wifi 网络上,它也会转到正确的网站,但在我的 Ubuntu 20.04 上,它仍然会转到以前的网站,而不会正确指向新网站。

过去我使用以下命令来清除缓存,但这不再起作用:

sudo /etc/init.d/nscd restart
Run Code Online (Sandbox Code Playgroud)

我发现了一些类似的帖子,并尝试了许多答案或评论中的解决方案,但到目前为止没有任何效果对我有用。

这是我大约 3~4 小时前更改的问题域的响应:

nslookup the-domain-name.org
Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
Name:   the-domain-name.org
Address: xx.xx.xx.xx (INCORRECT_IP, points to the DNS provider)
Name:   the-domain-name.org
Address: xx.xx.xx.xx (I am not sure if this IP is correct or not)
Run Code Online (Sandbox Code Playgroud)

当我查看/etc/resolv.conf文件内部时,它具有以下内容:

  GNU nano 4.8                    /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 trust-ad
search local

Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题,刷新/刷新缓存的正确方法是什么?有人刚刚说指向谷歌的DNS,该怎么做?

编辑:更新,

我不得不将另一个域移动到新的 IP,同样的问题再次出现。我尝试了这篇文章中的所有内容,但没有一个对我有用: https: //www.linuxuprising.com/2019/07/how-to-flush-dns-cache-on-linux-for.html

概括:

dig the-domain A <显示不正确的(旧)IP>

dig the-domain A @8.8.8.8 <显示正确的(新)IP>

nslookup the-domain <显示不正确的(旧)地址>

nslookup the-domain 8.8.8.8 <显示正确的(新)地址>

在任何浏览器中,chrome、Firefox、Brave,我都能看到旧网站。

And*_*her 1

resolvectl flush-caches

这可能取决于您是否使用systemd-networknetwork-manager。看起来你resolv.conf指向的127.0.0.53是一个systemd-resolved绑定到的环回地址。它维护自己的缓存并可以通过resolvectl. 使用systemd-resolved是 20.04 中的默认设置(如果使用systemd-networkd),但不是以前的 LTS 版本。

上游 DNS 服务器也可以缓存您的结果。如果你想专门查询DNS服务器,那么你可以使用命令nslookup the-domain-name.org the-dns-serverdig the-domain-name.org @the-dns-server。例如,要查询 Google 流行的quad8 服务器,这两个命令都可以。

nslookup example.com 8.8.8.8
dig example.com @8.8.8.8
Run Code Online (Sandbox Code Playgroud)