发现每次在/etc/resolv.conf 修改DNS之后,重启就会失
sudo vi /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 the actual nameservers.于是查找systemd-resolve相关资料 结果如下:
注意,上述三种处理方式是自动感知的(不需要特别的配置),完全取决于 /etc/resolv.conf 是否为软连接, 以及软连接指向的目标。
于是:
ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Feb 10 00:36 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf显然与上面的第二种情况类似,也就是说resolv.conf 现在归systemd管,果然找到了/etc/systemd/resolved.conf 文件:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes而里面也有我想找的DNS
sudo vim /etc/systemd/resolved.conf 然后修改DNS,例如:
[Resolve]
DNS=114.114.114.114
DNS=8.8.8.8
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes然后
systemctl restart systemd-resolved.service查看结果:
$ systemd-resolve --status
Global
DNS Servers: 114.114.114.114
8.8.8.8
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