Jon*_*mar 2 linux ubuntu dnsmasq resolv.conf systemd-resolved
运行 Ubuntu 17.10
我一直在尝试解决(呵呵)这个问题大约一个星期了,尽管有无数的谷歌搜索和大约 20 次不同的尝试,但我无法阻止 dnsmasq 定期导致我的 CPU 因以下违规者而飙升约一分钟:
systemd-resolved
systemd-journald
dnsmasq
监控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更改为 usenameserver 127.0.0.53
会导致尖峰几乎立即消失。
但是,由于网络管理器会定期更新该文件,因此我必须每小时更新一次。
# 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.1
search fios-router.home
Run Code Online (Sandbox Code Playgroud)
[main]
plugins=ifupdown,keyfile
[ifupdown]
managed=false
[device]
wifi.scan-rand-mac-address=no
Run Code Online (Sandbox Code Playgroud)
// All default except this at the very end for my wildcard DNS
address=/asmar.d/127.0.0.1
Run Code Online (Sandbox Code Playgroud)
nameserver 127.0.0.53
Run Code Online (Sandbox Code Playgroud)
lo.dnsmasq
:
nameserver 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
systemd-resolved
:
nameserver 127.0.0.53
Run Code Online (Sandbox Code Playgroud)
# interface-order(5)
lo.inet6
lo.inet
lo.@(dnsmasq|pdnsd)
lo.!(pdns|pdns-recursor)
lo
tun*
tap*
hso*
em+([0-9])?(_+([0-9]))*
p+([0-9])p+([0-9])?(_+([0-9]))*
@(br|eth)*([^.]).inet6
@(br|eth)*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
@(br|eth)*([^.]).inet
@(br|eth)*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
@(br|eth)*
@(ath|wifi|wlan)*([^.]).inet6
@(ath|wifi|wlan)*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
@(ath|wifi|wlan)*([^.]).inet
@(ath|wifi|wlan)*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
@(ath|wifi|wlan)*
ppp*
*
Run Code Online (Sandbox Code Playgroud)
systemd-resolve --status
:Global
DNS Servers: 127.0.0.1
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 5 (br-b1f5461ac410)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 4 (docker0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 3 (wlp62s0)
Current Scopes: none
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
Link 2 (enp61s0)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 8.8.8.8
8.8.4.4
::1
Run Code Online (Sandbox Code Playgroud)
如何在仍然使用我的通配符域名的同时解决此问题?
可选:如何在使用 Google DNS 时实现此目的?
请不要建议增加并发 dns 查询。那不是解决办法。
看起来您可能dnsmasq
在 127.0.0.1 中有进程,在 127.0.0.53 中有进程在systemd-resolved
彼此之间来回传递查询,从而导致循环。即使dnsmasq
单独也可能能够循环,因为默认情况下,它/etc/resolv.conf
会查找真正的 DNS 服务器以用于它没有信息的名称。
您的 DNS 配置可能有很多层:
NetworkManager
,它可以配置为覆盖信息并dnsmasq
改为使用,但目前没有这样配置。NetworkManager
配置为使用该resolvconf
工具更新真实的/etc/resolv.conf
. 并且dnsmasq
可能包括一个插入配置,resolvconf
用于覆盖 DHCP 接收的任何 DNS 服务,并在dnsmasq
运行时使用 127.0.0.1 。resolvconf
,但显然被dnsmasq
.我还不明白的是 127.0.1.1 和 127.0.0.53 来自哪里。它们是否可能dnsmasq
在 Ubuntu 的默认配置中提及?
正如在 的注释中所说/etc/resolv.conf
,运行此命令以查看有关systemd-resolved
配置的更多信息:
systemd-resolve --status
Run Code Online (Sandbox Code Playgroud)
还要检查/run/resolvconf/interface/
目录的内容:这是该resolvconf
工具收集从各种来源获得的所有 DNS 服务器信息的地方。在/etc/resolvconf/interface-order
将确定,其中每个源极被检查,直到一个环回地址遇到或3台DNS服务器已经上市真实的顺序/etc/resolv.conf
。
由于您使用的dnsmasq
是设置通配符域,因此您希望保留127.0.0.1
在您的/etc/resolv.conf
- 但您希望配置dnsmasq
为不使用该文件,而是从其他地方获取它应该使用的 DNS 服务器。
如果/run/NetworkManager/resolv.conf
包含您通过 DHCP 从您的 ISP 获得的那些 DNS 服务器,您可以dnsmasq
通过将此行添加到其配置中来轻松使用它:
resolv-file=/run/NetworkManager/resolv.conf
Run Code Online (Sandbox Code Playgroud)
这告诉从dnsmasq
何处获取 DNS 信息,了解它尚不知道的内容。所以,如果你想使用谷歌DNS,您可以配置dnsmasq
与
resolv-file=/etc/google-dns-resolv.conf
Run Code Online (Sandbox Code Playgroud)
并将 Google DNS 的 DNS 配置行以通常的格式放入/etc/google-dns-resolv.conf
.
归档时间: |
|
查看次数: |
3596 次 |
最近记录: |