如何将 DNS 设置重置为默认值?

如何将 DNS 设置重置为默认值?

在学习 DNS 时,我安装了太多应用程序,例如 BIND 和 DNSmasq,并对 /etc/resolve.conf 做了一些更改

现在我想将 DNS 设置重置为默认值?我已经删除了 DNSmasq 和我记得的东西,但是有没有办法将 DNS 设置重置为默认值,而不是重新安装系统?

答案1

首先,您的 /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
#DNSOverTLS=no
#Cache=yes
#DNSStubListener=yes

然后运行:sudo rm /etc/resolv.conf && sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

并检查你的 systemd-resolved 是否已启用:systemctl status systemd-resolved.service如果没有,则启用它:systemctl enable systemd-resolved.service并启动:systemctl start systemd-resolved.service

看来,仅此而已。

相关内容