/etc/resolv.conf
是一个链接,指向/run/systemd/resolve/stub-resolv.conf
,
ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ ll /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Sep 30 14:40 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
这两个(resolv.conf
和 stub-resolv.conf
)文件时间每次重启后会重新生成,所以单纯修改/etc/resolv.conf 后续会被覆盖
ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ ll
total 8
drwxr-xr-x 2 systemd-resolve systemd-resolve 120 Sep 30 18:10 ./
drwxr-xr-x 23 root root 580 Sep 30 18:11 ../
srw-rw-rw- 1 systemd-resolve systemd-resolve 0 Sep 30 18:10 io.systemd.Resolve=
srw------- 1 systemd-resolve systemd-resolve 0 Sep 30 18:10 io.systemd.Resolve.Monitor=
-rw-r--r-- 1 systemd-resolve systemd-resolve 930 Sep 30 18:10 resolv.conf
-rw-r--r-- 1 systemd-resolve systemd-resolve 920 Sep 30 18:10 stub-resolv.conf
resolvectl status
用来查看当前DNS
ubuntu@VM-4-13-ubuntu:/opt$ sudo resolvectl status
GlobalProtocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedresolv.conf mode: stubLink 2 (eth0)Current Scopes: DNSProtocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 183.60.83.19DNS Servers: 183.60.83.19 183.60.82.98Link 3 (docker0)Current Scopes: noneProtocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedLink 10 (br-ef5110e42154)Current Scopes: noneProtocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
查询了一些资料说是修改sudo vi /etc/systemd/resolved.conf
这个文件
[Resolve]
DNS=8.8.8.8 114.114.114.114
我修改后重启,resolv.conf
这个文件的内容是修改了的,但是的stub-resolv.conf
的内容还是没有修改,但是/etc/resolv.conf
是指向stub-resolv.conf
的,所以我改了一下链接的引用让他指向/run/systemd/resolve/resolv.conf
ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ sudo rm /etc/resolv.conf
ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.confubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ ll /etc/resolv.conf
lrwxrwxrwx 1 root root 32 Sep 30 14:46 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
resolvectl status
查看一下就出来了配置的DNS
ubuntu@VM-4-13-ubuntu:/run/systemd/resolve$ resolvectl status
GlobalProtocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedresolv.conf mode: uplinkDNS Servers: 8.8.8.8 114.114.114.114Link 2 (eth0)Current Scopes: DNSProtocols: +DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedDNS Servers: 183.60.83.19 183.60.82.98Link 3 (docker0)Current Scopes: noneProtocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupportedLink 4 (br-ef5110e42154)Current Scopes: noneProtocols: -DefaultRoute -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
这样就关联上了,但还有些疑惑不太明白,后面再学习~
1.自动生成的机制是怎么样的?
2.Global的 resolv.conf mode: stub ==> resolv.conf mode: uplink,这里受什么控制?