我已经阅读了 systemd-resolved.service https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html并了解了处理 /etc/resolv.conf 的四种模式。
我读了好几遍,但是对于如何确定我作为普通用户应该选择哪种模式的/etc/resolv.conf仍然感到困惑。
例如,我尝试添加一些自定义 dns 服务器,因此,
- 在 /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。
- 如果将 /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)