ubuntu20.04/etc/resolv.conf 语法语义解释
/etc/resolv.conf
是一个配置文件,用于指定系统如何查找域名对应的IP地址。在 Ubuntu 20.04 中,这个文件通常由 systemd-resolved
服务管理,并且通常不应手动编辑。
/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 directly to
# all known uplink DNS servers.
#
# Third party programs must not access this file directly, but only through the
# interface provided by the systemd-resolved service.
#
# Note that the resolv.conf(5) manual page indicates that programs
# should use the nameserver information provided by the resolver,
# and that this file is not intended to be edited directly.
#
# However, some Linux distributions default to including this file
# and others install packages that require it to be configured with
# real DNS servers. In this case, you may edit it as you like, as
# long as you keep the nameserver lines.
如果你需要修改 DNS 设置,你可以使用 nmcli
命令或者 systemd-resolve
命令。例如,使用 nmcli
设置 DNS 服务器:
nmcli connection modify <connection-name> ipv4.dns "8.8.8.8,8.8.4.4"
nmcli connection up <connection-name>
替换 <connection-name>
为你的网络连接名称,8.8.8.8
和 8.8.4.4
是你想要设置的 DNS 服务器地址。
请注意,如果你直接编辑 /etc/resolv.conf
,你的更改可能会在下次服务更新或网络重连时被覆盖。因此,推荐使用上述命令来管理 DNS 设置。
评论已关闭