我有一台 Ubuntu 服务器 (20.04) (SERVER),正在其上运行 dnsmasq。这台机器的本地 IP 为 SERVERADDRESS
我在同一个网络上有一台 Macbook Pro(客户端)——我更新了 MBP 上的 DNS 规则,使其指向 SERVERADDRESS
我可以在 CLIENT 上 nslookup 任何域,它都能很好地解析。但是,如果我尝试 nslookup SERVERADDRESS,它会说服务器找不到它。此外,它会反向输出,如 SSERDDAREVRES.in-addr.arpa: NXDOMAIN
另外 - 我尝试在 example.com 的服务器上设置自定义域。当我在服务器上运行 nslookup example.com 时,我得到了
Server: 127.0.1.1
Address: 127.0.1.1#53
Name: example.com
Address: 127.0.0.1
正如预期的那样
然而,当我在 CLIENT 上执行同样操作时,我得到了
Server: SERVERADDRESS
Address: SERVERADDRESS#53
Non-authoritative answer:
Name: example.com
Address: 93.184.216.34
这是意料之外的,因为他们应该使用相同的 DNS(服务器)。
我是否需要在客户端上执行其他操作来强制它使用服务器 DNS?
编辑:根据评论添加两台机器的挖掘输出注意:SERVERADDRESS 是本地 IP 地址(192.168。...)在服务器上:
USERNAME@SERVERNAME:/$ dig example.com
; <<>> DiG 9.16.1-Ubuntu <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27740
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 0 IN A 127.0.0.1
;; Query time: 0 msec
;; SERVER: 127.0.1.1#53(127.0.1.1)
;; WHEN: Wed Jan 20 18:21:35 CST 2021
;; MSG SIZE rcvd: 56
USERNAME@SERVERNAME:/$ dig example.com @SERVERADDRESS
; <<>> DiG 9.16.1-Ubuntu <<>> example.com @SERVERADDRESS
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45224
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: d71c1a5e56f69c9e010000006008ca08a1e5d4fd5b1af968 (good)
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 81320 IN A 93.184.216.34
;; Query time: 0 msec
;; SERVER: 192.168.1.5#53(192.168.1.5)
;; WHEN: Wed Jan 20 18:25:44 CST 2021
;; MSG SIZE rcvd: 84
在客户端:
CLIENTMACHINENAME:~ CLIENTUSERNAME$ dig example.com
; <<>> DiG 9.10.6 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30613
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 81427 IN A 93.184.216.34
;; Query time: 62 msec
;; SERVER: SERVERADDRESS#53(SERVERADDRESS)
;; WHEN: Wed Jan 20 19:23:57 EST 2021
;; MSG SIZE rcvd: 56
CLIENTMACHINENAME:~ CLIENTUSERNAME$ dig example.com @192.168.1.5
; <<>> DiG 9.10.6 <<>> example.com @SERVERADDRESS
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44288
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 81331 IN A 93.184.216.34
;; Query time: 36 msec
;; SERVER: SERVERADDRESS#53(SERVERADDRESS)
;; WHEN: Wed Jan 20 19:25:33 EST 2021
;; MSG SIZE rcvd: 56
这是我的 systemd 解析的配置文件:
# 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
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=yes
DNSStubListener=no
ReadEtcHosts=yes