Debian 12 使用 systemd-resolved 设置 DNS 服务器

打开 /etc/resolv.conf 文件,发现由 systemd-resolved 进行管理,不要直接修改该文件。

# This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs should typically 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.

search .

配置

systemd-resolved 服务的配置路径为 /etc/systemd/resolved.conf

按下面的示例配置即可

[Resolve]
DNS=223.5.5.5 119.29.29.29 1.1.1.1

重启服务

systemctl restart systemd-resolved.service

本文链接:

https://blog.nkxingxh.top/archives/565/
1 + 6 =
快来做第一个评论的人吧~