每次在/etc/resolv.conf 修改DNS之后,重启服务器DNS就会重置为127.0.0.53
解决过程
- 查看/etc/resolv.conf文件
➜ ~ 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
options edns0
- 发现问题
从/etc/resolv.conf
的注释中发现systemd-resolved
为本地应用程序提供了DNS解析服务。通过 systemd-resolved 在本地回环网口 127.0.0.53 上提供的本地DNS服务器。 应用程序可以直接向 127.0.0.53 发送DNS请求,从而直接使用 systemd-resolved 提供的解析服务。
解决方法
修改/etc/systemd/resolved.conf
- 打开/etc/systemd/resolved.conf
vim /etc/systemd/resolved.conf
- 修改DNS
[Resolve]
DNS=8.8.8.8
DNS=8.8.4.4
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes
- 重启服务
systemctl restart systemd-resolved.service
- 查看结果
➜ ~ systemd-resolve --status
Global
DNS Servers: 8.8.8.8
114.114.114.114
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
文章来源:https://www.cnaaa.net,转载请注明出处:https://www.cnaaa.net/archives/5207