Linux dns默认是127.0.0.53,在/etc/resolve.conf中存在 nameserver 127.0.0.53,修改后临时有效,每次重启依旧是127.0.0.53,因为这是系统生成的文件。

主机到本地DNS服务器(127.0.0.53)通常都是递归的方式进行查询,而本地DNS服务器与顶级域名服务器···(一级,二级,三级),通常都是迭代。

root@tssh:~# cat /etc/resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# 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 "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically 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:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad

从/etc/resolv.conf的配置文件的注释来看,告诉我们不要修改这个文件,这个文件由systemd-resolved服务管理,这是一个动态文件。通过查看端口得知确实有这么个端口

root@tssh:~# ss -lntp | grep 53                                                                                                 
LISTEN 0      4096   127.0.0.53%lo:53         0.0.0.0:*    users:(("systemd-resolve",pid=34041,fd=14))                           
LISTEN 0      4096         0.0.0.0:8181       0.0.0.0:*    users:(("nginx",pid=2253,fd=52),("nginx",pid=2222,fd=52))             
LISTEN 0      4096         0.0.0.0:443        0.0.0.0:*    users:(("nginx",pid=2253,fd=38),("nginx",pid=2222,fd=38))             
LISTEN 0      4096            [::]:80            [::]:*    users:(("nginx",pid=2253,fd=31),("nginx",pid=2222,fd=31))             
LISTEN 0      4096            [::]:8181          [::]:*    users:(("nginx",pid=2247,fd=53),("nginx",pid=2222,fd=53))             
LISTEN 0      4096            [::]:8181          [::]:*    users:(("nginx",pid=2253,fd=59),("nginx",pid=2222,fd=59))             
LISTEN 0      4096               *:45367            *:*    users:(("cri-dockerd",pid=1180,fd=10))

通过配置systemd-resolved来解决DNS无法解析的问题

root@tssh:~# vi /etc/systemd/resolved.conf
[Resolve]
DNS=192.168.30.253
Domains=test.local    

重启生效

root@tssh:~# systemctl restart systemd-resolved.service
root@tssh:~# resolvectl status
Global
         Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub
Current DNS Server: 192.168.30.253
       DNS Servers: 192.168.30.253
        DNS Domain: test.local

Link 2 (ens33)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.30.253
       DNS Servers: 192.168.30.253
        DNS Domain: test.local

Link 3 (docker0)
Current Scopes: none
     Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 4 (kube-ipvs0)
Current Scopes: none
     Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 5 (tunl0)
Current Scopes: none
     Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Copyright © https://yan-jian.com 2023 all right reserved更新时间: 2024-01-11 10:31:50

results matching ""

    No results matching ""