Linux/DNS

Linux/DNS

systemd-resolved

较新版的 Ubuntu 默认启用 systemd-resolved 作为本地 DNS 服务器。/etc/resolv.conf 是 /run/systemd/resolve/stub-resolv.conf 的符号链接。

systemd-resolved 监听在 lo 的 127.0.0.53 地址(硬编码,无法更改监听IP或网卡)的 53 端口。(本地回环 127.0.0.0/8 里任何地址等效。systemd-resolved 监听 127.0.0.53:53 后,其他程序无法再监听 127.0.0.1:53)

systemctl status systemd-resolved
systemd-resolve --status

systemd-resolved 的主要功能包括: DNS 缓存,DoH, DoT, dnsseq 支持等。但不能替代 dnsmasq (一个原因是 systemd-resolved 仅支持本机的 DNS 请求)。

配置 systemd-resolved

/etc/systemd/resolved.conf

[Resolve]
DNS=192.168.35.1 fd7b:d0bd:7a6e::1
Domains=~.

禁用 systemd-resolved 的本地 53 DNS 服务器

systemctl stop systemd-resolved

vim /etc/systemd/resolved.conf

[Resolve]
DNS=114.114.114.114
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
DNSStubListener=no

ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

systemctl start systemd-resolved


Last update: 2020-08-03 02:55:54 UTC