我有点不知所措。我可以对地址“imap.comcast.net”执行 nslookup 和 dig,但如果我尝试 ping 它或从我的应用程序连接到它,我会得到“名称解析暂时失败”的信息。我的 DNS 配置肯定出了问题,但我不确定是什么问题。
> ping imap.comcast.net
ping: imap.comcast.net: Temporary failure in name resolution
> systemd-resolve --status --no-pager
Global
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 2 (ens3)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 10.0.0.2
DNS Domain: ec2.internal
> 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 "systemd-resolve --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
search ec2.internal
更多法医信息 /etc/resolv.conf 是一个符号链接,如下所示
> readlink -f /etc/resolv.conf
/run/systemd/resolve/stub-resolv.conf
如果我更改符号链接并重新启动 systemd.resolve,我可以 ping 该地址,但它似乎禁用了 dns 缓存
>sudo service systemd-resolved stop
>sudo rm -f /etc/resolv.conf
>sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
>sudo service systemd-resolved start
>ping imap.comcast.net
>sudo systemd-resolve --statistics
DNSSEC supported by current servers: no
Transactions
Current Transactions: 0
Total Transactions: 0
Cache
Current Cache Size: 0
Cache Hits: 0
Cache Misses: 0
DNSSEC Verdicts
Secure: 0
Insecure: 0
Bogus: 0
Indeterminate: 0
答案1
我想我以前遇到过这个问题。我使用了这个问题中的第一个答案来解决这个问题: resolvconf 和 NetworkManager 设置的名称服务器错误
答案是更改 resolv.conf 符号链接:
sudo rm -f /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
reboot
答案2
对我来说,答案是我的 DNS 条目缺失网盘设置。我手动编辑了它们(在我的情况下是 /etc/netplan/50-cloud-init.yaml,但我意识到这可能特定于我的环境,并且可能不会“坚持”)。
我变了
network:
ethernets:
ens160:
addresses:
- 10.8.25.116/28
dhcp4: false
gateway4: 10.8.25.113
nameservers:
addresses: []
search: []
version: 2
到
network:
ethernets:
ens160:
addresses:
- 10.8.25.116/28
dhcp4: false
gateway4: 10.8.25.113
nameservers:
addresses: [8.8.8.8,4.2.2.2]
search: []
version: 2
然后应用它
netplan apply
答案3
这可能看起来很疯狂...但是经过长时间的研究,在互联网上发现了类似的情况......这对我来说很有帮助 - 更新软件包!
具体来说,这些命令:
systemctl disable systemd-resolved
systemctl stop systemd-resolved
reboot
apt update && apt upgrade
reboot
systemctl enable systemd-resolved
systemctl start systemd-resolved
特别是,我认为systemd包裹不知为何被损坏了……
PS:不要立即尝试用额头解决问题!请先更新/重新安装软件包!节省您的时间;-)
答案4
我刚刚遇到这个问题,这让我很抓狂。我检查了 DNS 和所有本地主机网络。一切都很完美。主机网络没有配置错误:对具有相同配置的其他主机的比较分析可以正常工作,但这个主机却不行。为什么?!?!?
答案是 Internet 网关中的错误 NAT 规则。
<捂脸>DNS 错误消息是问题的症状,而不是实际问题本身。</facepalm>
快速检查 Internet GW 中缺失或不正确的 NAT 规则可以为您节省大量时间...