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

Ada*_*dam 5 networking dns 18.04

在学习 DNS 的过程中,我安装了太多 BIND 和 DNSmasq 等应用程序并对 /etc/resolve.conf 进行了一些更改

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

Gan*_*net 6

首先,您的 /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
Run Code Online (Sandbox Code Playgroud)

然后运行: 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

似乎,仅此而已。

  • 不适合我。Chrome 仍然给出 DNS_PROBE_FINISHED_BAD_CONFIG。状态 systemd-resolved.service 给出“另一个进程正在侦听 tcp socker 127.0.0.53:53”“关闭本地 DNS 存根支持” (2认同)