DNS系统偶尔解析域名失败

Sla*_* II 5 networking dns

我正在运行Xubuntu…

$ cat /etc/issue
Ubuntu 17.04

$ uname -a
Linux intrepid 4.10.0-33-generic #37-Ubuntu SMP Fri Aug 11 10:55:28 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud)

...并通过无线网络连接。

但是,DNS 系统的行为很奇怪,有时无法解析域名。

当我尝试手动解析某些域名时,它给了我以下错误:

$ nslookup google.com
Server:     127.0.0.53
Address:    127.0.0.53#53

** server can't find google.com: REFUSED
Run Code Online (Sandbox Code Playgroud)

这是我电脑上配置的所有 DNS 服务器的列表:

$ nmcli device show wlp3s0 | grep IP4.DNS
IP4.DNS[1]:                             192.168.1.1
IP4.DNS[2]:                             8.8.4.4
IP4.DNS[3]:                             8.8.8.8
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试解析域名并告诉它直接将我的路由器用作 DNS 服务器(首先应该自动使用)时,它可以完美运行:

$ nslookup google.com - 192.168.1.1
Server:     192.168.1.1
Address:    192.168.1.1#53

Non-authoritative answer:
Name:   google.com
Address: 173.194.122.238
…
Run Code Online (Sandbox Code Playgroud)

为什么域名解析失败?默认情况下它尝试使用什么服务器?

resolve.conf的看起来像这样:

$ cat /etc/resolv.conf 
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
Run Code Online (Sandbox Code Playgroud)

任何提示将不胜感激,谢谢!


$ systemd-resolve --status. 我使用的界面是wlp3s0.

cry*_*bhu 2

我做了 @jringoot 在他的评论中建议的操作:
mv /etc/resolv.conf /etc/resolv.conf_orig
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
基本上复制了原始的 resolv.conf 文件并创建了另一个文件。

我检查了一下,发现它仍在使用路由器 dns。
然后我打开该文件
vim /etc/resolv.conf
并将名称服务器从路由器 dns 编辑为 1.1.1.1 (CloudFlare DNS)
,即填写: nameserver 1.1.1.1

当我使用它进行检查时,
nslookup google.com
现在显示它正在使用我指定的 DNS:
nslookup google.com
Server: 1.1.1.1
Address: 1.1.1.1#53

Non-authoritative answer:
Name: google.com
Address: 172.217.160.14