08-21-2022, 07:40 AM
发现每次在/etc/resolv.conf 修改DNS之后,重启就会失效。在执行
vi /etc/resolv.conf
之后发现有以下输出:
This file is managed by man
ystemd-resolved(8). Do not edit.This is a dynamic resolv.conf file for connecting local clients to the
internal DNS stub resolver of systemd-resolved. This file lists all configured search domains.Run "systemd-resolve --status" to see details about the uplink DNS servers currently in use.Third party programs must not access this file directly, but only through the
symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,replace this symlink by a static file or a different symlink.
See man
ystemd-resolved.service(8) for details about the supported modes of operation for /etc/resolv.conf.
于是:
ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Feb 18 2020 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
也就是说resolv.conf 现在归systemd管,果然找到了/etc/systemd/resolved.conf 文件:
This file is part of systemd.
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
Entries in this file show the compile time defaults.
You can change settings by editing this file.
Defaults can be restored by simply deleting this file.
See resolved.conf(5) for details
[b]解决方法[/b]
vi /etc/systemd/resolved.conf
然后修改DNS,例如:上面的
然后,
systemctl restart systemd-resolved.server
查看结果,DNS已经修改过来了。
vi /etc/resolv.conf
之后发现有以下输出:
This file is managed by man
![[Image: confused.png]](https://note.224236.xyz/images/smilies/confused.png)
internal DNS stub resolver of systemd-resolved. This file lists all configured search domains.Run "systemd-resolve --status" to see details about the uplink DNS servers currently in use.Third party programs must not access this file directly, but only through the
symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,replace this symlink by a static file or a different symlink.
See man
![[Image: confused.png]](https://note.224236.xyz/images/smilies/confused.png)
于是:
ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Feb 18 2020 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
也就是说resolv.conf 现在归systemd管,果然找到了/etc/systemd/resolved.conf 文件:
This file is part of systemd.
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
Entries in this file show the compile time defaults.
You can change settings by editing this file.
Defaults can be restored by simply deleting this file.
See resolved.conf(5) for details
[Resolve]
DNS=8.8.8.8 ##原来不是这样,这是修改过的;
DNS=8.8.4.4 ##这一行原来没有,改好的;
FallbackDNS=
Domains=
LLMNR=no
MulticastDNS=no
DNSSEC=no
Cache=yes
DNSStubListener=yes
而里面也有我想找的DNSDNS=8.8.8.8 ##原来不是这样,这是修改过的;
DNS=8.8.4.4 ##这一行原来没有,改好的;
FallbackDNS=
Domains=
LLMNR=no
MulticastDNS=no
DNSSEC=no
Cache=yes
DNSStubListener=yes
[b]解决方法[/b]
vi /etc/systemd/resolved.conf
然后修改DNS,例如:上面的
然后,
systemctl restart systemd-resolved.server
查看结果,DNS已经修改过来了。