Eu li sobre systemd-resolved.service https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html e aprendi quatro modos de manipulação /etc/resolv.conf.
- /run/systemd/resolve/stub-resolv.conf
- /usr/lib/systemd/resolv.conf
- /run/systemd/resolve/resolv.conf
- /etc/resolv.conf pode ser gerenciado por outro pacote
Eu o li várias vezes, mas ainda me sinto confuso sobre como determinar qual modo de /etc/resolv.conf devo escolher como um usuário normal.
Por exemplo, tento adicionar alguns servidores DNS personalizados, então,
- Adicione DNS=8.8.8.8 8.8.4.4 em /etc/systemd/resolved.conf e verifique se /run/systemd/resolve/resolv.conf, 8.8.8.8 e 8.8.4.4 existem nele.
- Se o link simbólico /run/systemd/resolve/resolv.conf para /etc/resolv.conf, 8.8.8.8 e 8.8.4.4 desaparecerem em /run/systemd/resolve/resolv.conf.
Atualização 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/systemd/resolve/resolv.conf
test@instance-1:/etc$ sudo reboot
test@instance-1:~$ cat /etc/resolv.conf
domain c.prime-poetry-197705.internal
search c.prime-poetry-197705.internal. google.internal.
nameserver 169.254.169.254
test@instance-1:~$ cat /run/systemd/resolve/resolv.conf
domain c.prime-poetry-197705.internal
search c.prime-poetry-197705.internal. google.internal.
nameserver 169.254.169.254
test@instance-1:~$ ls -alh /etc/resolv.conf
lrwxrwxrwx 1 root root 32 Mar 18 07:22 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
Atualização 2: links simbólicos de /etc/resolv.conf
test@instance-1:~$ sudo ln -sf /etc/resolv.conf /run/systemd/resolve/resolv.conf
test@instance-1:~$ ls -alh /run/systemd/resolve/resolv.conf
lrwxrwxrwx 1 root root 16 Mar 18 07:51 /run/systemd/resolve/resolv.conf -> /etc/resolv.conf
test@instance-1:~$ sudo reboot
test@instance-1:~$ ls -alh /run/systemd/resolve/resolv.conf
-rw-r--r-- 1 systemd-resolve systemd-resolve 603 Mar 18 07:52 /run/systemd/resolve/resolv.conf