当尝试在 Ubuntu 上使用 NetworkManager 的 ModemManager 修复 DNS 问题时,我在systemd-resolve --status连接时的输出中发现了这种差异。(pingip 有效,手动编辑/etc/resolv.conf可以解决问题,设置 FallbackDNS 也可以解决问题,但都有副作用。
工作安装 - PPP 调制解调器(Ubuntu 17.10)
Link 3 (wwp0s20u6)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 198.142.0.51
211.29.132.12
Run Code Online (Sandbox Code Playgroud)
安装损坏 - PPP 调制解调器(相同硬件 - Lubuntu 17.04)
Link 2 (wwp0s20u6)
Current Scopes: LLMNR/IPv4 LLMNR/IPv6
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Run Code Online (Sandbox Code Playgroud)
它们都是 Ubuntu 的版本,并且硬件相同。中的网络连接配置/etc/NetworkManager/system-connections …
所以我正在测试一个路由器,它向我网络上的所有机器添加了一些随机的 IPv6 地址,包括我的 DNS 服务器。不知何故,这些 IP 作为有效的 DNS 服务器被广播(不确定只有真正的路由器如何发送 IPv6 RA 数据包)但长话短说,现在我所有的机器都向一个不存在的 IP 地址发送 DNS 查询。
如果我重新启动resolved,systemctl restart systemd-resolved那么resolvectl仍然将这些虚假 IP 显示为有效的名称服务器。
它们被列在/etc/resolv.conf所以如果我在那里删除它们并重新启动systemd-resolved它只会再次添加虚假的 IP。
如果我查看日志,journalctl --unit=systemd-resolved它会告诉我虚假 IP 正在“降级功能模式”下运行,但没有告诉我从哪里找到这些 IP。
它从哪里获取这些错误的 IP 地址?是否有一些缓存文件我需要删除才能让它回到仅使用 IPv6 路由器广告提供的 IP?
我尝试在 Ubuntu 20.04 上使用 dnsmasq,但在端口 53 上与 systemd-resolved 发生端口冲突。因此,我找到了一些有关解决方案的建议,但它们似乎已过时或不适用于我的情况。
\n如果我禁用 systemd-resolved,一切都会变得缓慢,因为我似乎在等待超时:
\nsudo: unable to resolve host ubuntu: Temporary failure in name resolution\nRun Code Online (Sandbox Code Playgroud)\n所以基本上我输入的任何命令都需要 20 秒左右。
\n我想我需要像https://askubuntu.com/a/907249中的建议一样放入dns=default\n中的建议。但是,该文件不存在,并且不再是包的一部分:/etc/NetworkManager/NetworkManager.conf
$ dpkg -S /etc/NetworkManager/NetworkManager.conf\ndpkg-query: no path found matching pattern /etc/NetworkManager/NetworkManager.conf\nRun Code Online (Sandbox Code Playgroud)\n因此,我将其作为 20.04 标题的问题发布,而不是在那里添加 20 多个评论\xe2\x80\xa6
\n如果我禁用 systemd-resolve,我可以启动 dnsmasq,但一切仍然会出现“名称解析暂时失败”错误,如果我查看 dnsmasq 状态,它似乎也有问题:
\nubuntu@ubuntu:~$ sudo systemctl status dnsmasq.service\nsudo: unable to resolve host ubuntu: Temporary failure in name resolution\n\xe2\x97\x8f dnsmasq.service - dnsmasq - …Run Code Online (Sandbox Code Playgroud) 我已经阅读了 systemd-resolved.service https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html并了解了处理 /etc/resolv.conf 的四种模式。
我读了好几遍,但是对于如何确定我作为普通用户应该选择哪种模式的/etc/resolv.conf仍然感到困惑。
例如,我尝试添加一些自定义 dns 服务器,因此,
- 在 /etc/systemd/resolved.conf 中添加 DNS=8.8.8.8 8.8.4.4 并检查 /run/systemd/resolve/resolv.conf 中是否存在 8.8.8.8 和 8.8.4.4。
- 如果将 /run/systemd/resolve/resolv.conf 符号链接到 /etc/resolv.conf,则 /run/systemd/resolve/resolv.conf 中的 8.8.8.8 和 8.8.4.4 将消失。
更新 1:
test@instance-1:~$ cat /run/systemd/resolve/resolv.conf
...
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 8.8.8.8
nameserver 8.8.4.4
test@instance-1:/etc$ sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
test@instance-1:/etc$ ls -alh /etc/resolv.conf
lrwxrwxrwx 1 root root 32 Mar 18 07:22 /etc/resolv.conf -> …Run Code Online (Sandbox Code Playgroud) 使用systemd-resolved如何阻止、路由或解析域名到黑洞或无处地址。子域的奖励积分也是如此。
我在 中尝试了一个域/etc/hosts:
127.0.0.1 google.com
::1 google.com
Run Code Online (Sandbox Code Playgroud)
我也试过/etc/systemd/network/100-blocked.network:
[Match]
Name=wlp113s0
[Network]
Description="Just block the domain, and sub domains"
DNS=127.0.0.255
DNS=::1
[Resolve]
Domains=google.com
Run Code Online (Sandbox Code Playgroud)
sudo systemd-resolve --status:
Link 3 (wlp113s0)
Current Scopes: DNS
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 127.0.0.255
::1
2001:4888:3a:ff00:304:d::
2001:4888:39:ff00:308:d::
Run Code Online (Sandbox Code Playgroud)
例如使用dnsmasq我能够做到:
server=192.168.43.1
address=/google.com/0.0.0.0
# a very long list of "address=/domain/0"
Run Code Online (Sandbox Code Playgroud)
有关的:
我查看了 systemd-networkd 和 systemd-resolved:
我对一些话感到困惑:
systemd-resolved.service(8)
使用 LLMNR 协议将单标签名称路由到所有能够进行 IP 多播的本地接口。对以每个接口域之一结尾的主机名的查找被专门路由到匹配的接口。
systemd.network(5)
“搜索”和“仅路由”域都用于 DNS 查询的路由:查找以这些域结尾的主机名(因此,如果列出了任何“搜索域”,也会将单标签名称路由到为此接口配置的 DNS 服务器。
我的问题是:对于配置了“搜索域”并启用 LLMNR 的一堆接口的主机,单标签查找请求会去哪里?
我的困惑的更多细节:
systemd-resolved 是否可以像 avahi-browse 一样用于浏览 mdns 服务?
例如:
$ avahi-browse _smb._tcp
+ eno1 IPv6 PC1 Microsoft Windows Network local
+ eno1 IPv6 PC2 Microsoft Windows Network local
+ eno1 IPv6 PC3 Microsoft Windows Network local
+ eno1 IPv6 PC4 Microsoft Windows Network local
Run Code Online (Sandbox Code Playgroud)
但在同一网络中的另一台机器上,使用resolved,但查询给定服务的所有机器不起作用:
$ resolvectl --protocol=mdns service _smb._tcp.local
Resolve call failed: All attempts to contact name servers or networks failed
Run Code Online (Sandbox Code Playgroud)
但是涉及主机名的直接查询正在工作:
$ resolvectl --protocol=mdns service PC1._smb._tcp.local
PC1._smb._tcp.local: PC1.local:445 [priority=0, weight=0]
fe80::e4c2:d456:7856:45f1%4 -- link: eth0
(PC1/_smb._tcp/local)
-- Information acquired via protocol …Run Code Online (Sandbox Code Playgroud) 我在 Ubuntu 18.10 上遇到 SystemD 解析服务的问题 - 在我的无线网络上,我们有一个 IPv6 子网,它通过一些奇怪的网络设置(工作内容)隧道传输,不能用于 DNS 解析。
出于某种原因,即使我已将静态 DNS 配置设置/etc/systemd/resolved.conf.d/dns.conf为仅包含 IPv4 DNS 记录,并且 DHCP 从不通告 IPv6 DNS 服务器,但已解析总是在我的无线连接上向特定于连接的 DNS 配置添加一些时髦的 IPv6 地址,并且然后“回退”到它们并停止解析地址。
这是我的dns.conf(主要resolved.conf是默认的 - 那里什么都没有):
[Resolve]
DNS=172.18.1.254 8.8.8.8 8.8.4.4 1.1.1.1
DNSSEC=no
Run Code Online (Sandbox Code Playgroud)
(第一个DNS地址是本地路由器)
解析的全局配置(可以从 获得resolvectl status):
Global
LLMNR setting: no
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
Current DNS Server: 172.18.1.254
DNS Servers: 172.18.1.254
8.8.8.8
8.8.4.4
1.1.1.1
...
Link 2 (wlp2s0)
Current Scopes: …Run Code Online (Sandbox Code Playgroud) 我一直在努力通过以下设置在我的系统上全面使用 DNSSEC:
dnscrypt-proxy 在 127.0.0.1 上安装、启动并运行 require_dnssec = trueDNSSEC=yes和DNS=127.0.0.1nameserver 127.0.0.1在/etc/resolv.conf/run/systemd/resolve/resolv.conf 在 127.0.0.1 下面列出 8.8.8.8 和 8.8.8.4。
resolvectl status 显示
DNSSEC setting: yes
DNSSEC supported: yes
Current DNS Server: 127.0.0.1
DNS Servers: 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
在全局部分,但
DNSSEC setting: yes
DNSSEC supported: yes
Current DNS Server: 8.8.8.8
DNS Servers: 8.8.8.8
8.8.8.4
Run Code Online (Sandbox Code Playgroud)
在我的界面部分(为什么?)。
tcpdump使用 Web 浏览器、dig 或其他正常使用时,在 udp:53 上根本没有显示任何活动。我认为这意味着我的本地 dnscrypt-proxy 正在处理我系统上的所有 DNS …
我想开始systemd-resolved在 Oracle Linux 7.6 上使用。
我已经安装了systemd-networkd并且systemd-resolved. 我已启用这些服务并禁用了network和NetworkManager。
从可能的工作模式中,我想用作systemd-resolved本地解析器,并且出于兼容性原因,我想链接/etc/resolv.conf到/run/systemd/resolve/stub-resolv.conf应该指向的nameserver 127.0.0.53.
但是/run/systemd/resolve/stub-resolv.conf我的安装中缺少该文件。您能告诉我原因吗?/run/systemd/resolve/resolv.conf虽然存在。
我目前正在从事一个需要进行一些 DNS 故障排除的项目,但是我对美妙的网络世界还很陌生,并且对从哪里开始有点茫然。我的具体问题可能属于 RaspberryPi StackExchange,因此我将避免交叉发布。只是在这里寻找信息。
寻找信息,我被引导到resolv.conf(5)文件resolvconf(8),systemd-resolve(1), 和avahi似乎是的野兽。
我的带有 Raspbian Buster 的 Raspi 似乎avahi-daemon正在运行。我的 Ubuntu 18.04.4 LTS 有systemd-resolvedAND avahi-daemon。并resolvconf(8)协调两个(手册页仅在Ubuntu)?何时/etc/resolv.conf使用/忽略?
在 Ubuntu 上:
$ 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 …Run Code Online (Sandbox Code Playgroud) 运行 Ubuntu 17.10
我一直在尝试解决(呵呵)这个问题大约一个星期了,尽管有无数的谷歌搜索和大约 20 次不同的尝试,但我无法阻止 dnsmasq 定期导致我的 CPU 因以下违规者而飙升约一分钟:
systemd-resolvedsystemd-journalddnsmasq监控journalctl -f每次发生时我都会看到这一点:
达到最大并发 dns 查询数 (150)
伴随/前面是对某个域(通常是 ubuntu 连接检查)的疯狂请求循环,如下所示:
query[A] connectivity-check.ubuntu.com from 127.0.0.1
forwarded connectivity-check.ubuntu.com to 127.0.1.1
forwarded connectivity-check.ubuntu.com to 127.0.0.53
query[A] connectivity-check.ubuntu.com from 127.0.0.1
forwarded connectivity-check.ubuntu.com to 127.0.0.53
query[AAAA] connectivity-check.ubuntu.com from 127.0.0.1
forwarded connectivity-check.ubuntu.com to 127.0.0.53
query[AAAA] connectivity-check.ubuntu.com from 127.0.0.1
forwarded connectivity-check.ubuntu.com to 127.0.0.53
query[A] connectivity-check.ubuntu.com from 127.0.0.1
forwarded connectivity-check.ubuntu.com to 127.0.0.53
query[AAAA] connectivity-check.ubuntu.com from 127.0.0.1
forwarded connectivity-check.ubuntu.com to 127.0.0.53
Run Code Online (Sandbox Code Playgroud)
我发现将/etc/resolv.conf更改为 …
systemd-resolved ×12
dns ×7
dnsmasq ×3
resolv.conf ×3
systemd ×3
avahi ×2
ubuntu ×2
centos ×1
dig ×1
dnscrypt ×1
fedora ×1
ipv6 ×1
linux ×1
mdns ×1
networking ×1
oracle-linux ×1
resolvconf ×1
rhel ×1