DNS 解析器无法按预期处理本地网络地址

DNS 解析器无法按预期处理本地网络地址

我是 Fedora 的老用户,但现在我的网络上有一个 Ubuntu (18.04.04 LTS) 系统(如果有必要的话,它是一个 Jetson Nano 开发套件)。我无法解析本地网络上的主机地址。我在本地网络上运行 dnsmasq 来为该网络上的所有计算机提供缓存 DNS 和 DHCP 服务,它适用于我的所有 Fedora 主机。但是,本地网络上的主机地址无法从 ubuntu 计算机解析,但可以解析外部 Internet 地址。例如,这是“dig”从同一网络上的其中一台 Fedora 计算机生成的结果:

[hwuser@b00 ~]$ dig hw-fs
; <<>> DiG 9.11.6-P1-RedHat-9.11.6-5.P1.fc30 <<>> hw-fs
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18123
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;hw-fs.             IN  A

;; ANSWER SECTION:
hw-fs.          0   IN  CNAME   e04.
e04.            0   IN  A   192.168.36.192

;; Query time: 1 msec
;; SERVER: 192.168.36.3#53(192.168.36.3)
;; WHEN: Wed Feb 26 10:06:56 EST 2020
;; MSG SIZE  rcvd: 67

以下是 ubuntu 机器生成的内容:

hwuser@j00:~$ dig hw-fs
; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> hw-fs
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 42973
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;hw-fs.             IN  A

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Mon Jan 29 07:07:31 EST 2018
;; MSG SIZE  rcvd: 34

由此可见/etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53

我不熟悉 systemd-resolve,但运行systemd-resolve --status会产生:

hwuser@j00:~$ systemd-resolve --status
Global
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 3 (eth0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.36.3
          DNS Domain: ~.

Link 2 (dummy0)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

dig a14我还设法启用了 systemd-resolved 的调试信息。这是我从 ubuntu 机器上尝试时日志显示的内容:

Jan 29 07:46:52 j00 systemd-resolved[13114]: Got DNS stub UDP query packet for id 51024
Jan 29 07:46:52 j00 systemd-resolved[13114]: Looking up RR for a14 IN A.
Jan 29 07:46:52 j00 systemd-resolved[13114]: Sending response packet with id 51024 on interface 1/AF_INET.
Jan 29 07:46:52 j00 systemd-resolved[13114]: Processing query...

运行ip route结果如下:

default via 192.168.36.1 dev eth0 proto dhcp metric 100 
169.254.0.0/16 dev eth0 scope link metric 1000 
192.168.36.0/24 dev eth0 proto kernel scope link src 192.168.36.66 metric 100 

根据要求,运行'dpkg -l域名系统结果是:

hwuser@j00:~$ dpkg -l *dnsmasq*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                              Version                       Architecture                  Description
+++-=================================================-=============================-=============================-=======================================================================================================
un  dnsmasq                                           <none>                        <none>                        (no description available)
ii  dnsmasq-base                                      2.79-1                        arm64                         Small caching DNS proxy and DHCP/TFTP server
un  dnsmasq-base-lua                                  <none>                        <none>                        (no description available)

现在的内容是/etc/nsswitch.conf


# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         compat systemd
group:          compat systemd
shadow:         compat
gshadow:        files

hosts:          files mdns4_minimal [NOTFOUND=return] dns myhostname
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

添加我的 DNS 服务器地址后/etc/systemd/resolved.conf(虽然这不必手动完成,因为这是 dnsmasq 自动提供的全部功能):

hwuser@j00:~$ systemd-resolve --status
Global
         DNS Servers: 192.168.36.3
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 3 (eth0)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.36.3
          DNS Domain: ~.

Link 2 (dummy0)
      Current Scopes: none
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no

hwuser@j00:~$ ls -al /etc/resolv.conf
lrwxrwxrwx 1 root root 27 Oct 22  2018 /etc/resolv.conf -> /run/resolvconf/resolv.conf

hwuser@j00:~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53

我觉得这里缺少一些关键部分,有些配置不正确。如何让 systemd-resolve 使用 eth0 上的 DNS 服务器?

我看到了这个问题:Ubuntu 客户端忽略本地网络上的 DNS 服务器,但答案并不能解决我的问题,因为我不想让我的 ubuntu 机器上运行 dnsmasq(我已经在网络上运行它了,所以我不需要重复)。

相关内容