小编net*_*caf的帖子

阐明 systemd-resolved 中处理 /etc/resolv.conf 的四种模式

我已经阅读了 systemd-resolved.service https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html并了解了处理 /etc/resolv.conf 的四种模式。

  1. /run/systemd/resolve/stub-resolv.conf
  2. /usr/lib/systemd/resolv.conf
  3. /run/systemd/resolve/resolv.conf
  4. /etc/resolv.conf 可能由其他包管理

我读了好几遍,但是对于如何确定我作为普通用户应该选择哪种模式的/etc/resolv.conf仍然感到困惑。

例如,我尝试添加一些自定义 dns 服务器,因此,

  1. 在 /etc/systemd/resolved.conf 中添加 DNS=8.8.8.8 8.8.4.4 并检查 /run/systemd/resolve/resolv.conf 中是否存在 8.8.8.8 和 8.8.4.4。
  2. 如果将 /run/systemd/resolve/resolv.conf 符号链接到 /etc/resolv.conf,则 /run/systemd/resolve/resolv.conf 中的 8.8.8.8 和 8.8.4.4 将消失。

更新 1:

test@instance-1:~$ cat /run/systemd/resolve/resolv.conf 
...
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 8.8.8.8
nameserver 8.8.4.4

test@instance-1:/etc$ sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf 
test@instance-1:/etc$ ls -alh /etc/resolv.conf 
lrwxrwxrwx 1 root root 32 Mar 18 07:22 /etc/resolv.conf -> …
Run Code Online (Sandbox Code Playgroud)

systemd systemd-resolved

6
推荐指数
1
解决办法
6884
查看次数

标签 统计

systemd ×1

systemd-resolved ×1