阅读量:100
resolvconf 在 Ubuntu 中的更新机制主要依赖于 systemd-resolved 服务。systemd-resolved 是一个用于处理 DNS 解析的服务,它取代了传统的 resolvconf 工具。systemd-resolved 使用一个名为 DNS 的单元文件来管理 DNS 解析设置。
以下是 resolvconf 在 Ubuntu 中的更新机制:
- 当系统启动时,
systemd-resolved会读取/etc/resolv.conf文件中的 DNS 服务器设置。 systemd-resolved会根据/etc/systemd/resolved.conf文件中的配置以及/etc/NetworkManager/system-connections/*.nmconnection文件中的网络连接设置来自动配置 DNS 解析器。- 当网络连接状态发生变化时(例如,当新的 Wi-Fi 网络连接建立时),
NetworkManager会通知systemd-resolved更新 DNS 设置。 systemd-resolved会将更新后的 DNS 设置写入/run/systemd/resolved/stub-resolv.conf文件,该文件是/etc/resolv.conf文件在系统启动时的临时副本。- 在系统启动过程中,
systemd-resolved会将/run/systemd/resolved/stub-resolv.conf文件中的 DNS 设置复制回/etc/resolv.conf文件。 - 用户可以使用
resolvconf命令手动更新/etc/resolv.conf文件中的 DNS 设置,但这通常不是推荐的做法,因为它可能导致网络连接问题。相反,建议使用systemd-resolved服务来管理 DNS 解析设置。
总之,resolvconf 在 Ubuntu 中的更新机制主要依赖于 systemd-resolved 服务。当网络连接状态发生变化时,systemd-resolved 会自动更新 DNS 解析设置,并将这些设置写入 /etc/resolv.conf 文件。