Mac OS 10.14.6 不使用 /etc/resolver/test

Mac OS 10.14.6 不使用 /etc/resolver/test

我在虚拟机的主机上运行一个 DNS 服务器,其 IP 为 192.168.99.169

如果我运行 DNS 查询,我会得到以下响应

挖:

dig @192.168.99.169 hello-john.test

结果:

;; Warning: Message parser reports malformed message packet.

; <<>> DiG 9.10.6 <<>> @192.168.99.169 hello-john.test
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43698
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: Message has 8 extra bytes at end

;; QUESTION SECTION:
;hello-john.test.       IN  A

;; ANSWER SECTION:
hello-john.test.    300 IN  A   192.168.99.169

;; Query time: 17 msec
;; SERVER: 192.168.99.169#53(192.168.99.169)
;; WHEN: Sun Sep 29 09:50:18 CDT 2019
;; MSG SIZE  rcvd: 73

nslookup:

nslookup hello-john.test 192.168.99.169

结果:

Server:     192.168.99.169
Address:    192.168.99.169#53

Non-authoritative answer:
Name:   hello-john.test
Address: 192.168.99.169

对于 dns 服务器来说,一切都正常工作。如果我更新 mac 上的 dns 服务器,使唯一的 dns 服务器为 192.168.99.169,那么一切也会以相同的方式工作,但我不必指定 dns 服务器。例如:

更新 DNS 服务器

networksetup -setdnsservers Wi-Fi 192.168.99.169

挖:

dig hello-john.test
;; Warning: Message parser reports malformed message packet.

; <<>> DiG 9.10.6 <<>> hello-john.test
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6173
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: Message has 8 extra bytes at end

;; QUESTION SECTION:
;hello-john.test.       IN  A

;; ANSWER SECTION:
hello-john.test.    300 IN  A   192.168.99.169

;; Query time: 7 msec
;; SERVER: 192.168.99.169#53(192.168.99.169)
;; WHEN: Sun Sep 29 09:57:10 CDT 2019
;; MSG SIZE  rcvd: 73

nslookup:

nslookup hello-john.test

结果:

Server:     192.168.99.169
Address:    192.168.99.169#53

Non-authoritative answer:
Name:   hello-john.test
Address: 192.168.99.169

完全覆盖 DNS 服务器对我来说不起作用,因为需要搜索多个 IP 地址。

我将 DNS 服务器重置为普通 DNS 服务器。

networksetup -setdnsservers Wi-Fi 8.8.8.8

我创建一个文件/etc/resolver/test,内容如下:

domain test
nameserver 192.168.99.169
search_order 1
timeout 5

我可以使用 scutil 测试解析器是否正确加载:

scutil --dns

结果:

DNS configuration

resolver #1
  nameserver[0] : 8.8.8.8
  flags    : Request A records
  reach    : 0x00000002 (Reachable)

resolver #2
  domain   : local
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300000

resolver #3
  domain   : 254.169.in-addr.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300200

resolver #4
  domain   : 8.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300400

resolver #5
  domain   : 9.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300600

resolver #6
  domain   : a.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 300800

resolver #7
  domain   : b.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records
  reach    : 0x00000000 (Not Reachable)
  order    : 301000

resolver #8
  domain   : test
  nameserver[0] : 192.168.99.169
  timeout  : 5
  flags    : Request A records
  reach    : 0x00020002 (Reachable,Directly Reachable Address)
  order    : 1

DNS configuration (for scoped queries)

resolver #1
  nameserver[0] : 8.8.8.8
  if_index : 5 (en0)
  flags    : Scoped, Request A records
  reach    : 0x00000002 (Reachable)

但是当我运行 dig 或 nslookup 时,它没有使用解析器。我猜这与解析器配置的使用顺序有关。

挖:

dig hello-john.test

结果:

; <<>> DiG 9.10.6 <<>> hello-john.test
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 39721
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;hello-john.test.       IN  A

;; AUTHORITY SECTION:
.           86388   IN  SOA a.root-servers.net. nstld.verisign-grs.com. 2019092900 1800 900 604800 86400

;; Query time: 16 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sun Sep 29 10:06:50 CDT 2019
;; MSG SIZE  rcvd: 119

nslookup:

nslookup hello-john.test

结果:

Server:     8.8.8.8
Address:    8.8.8.8#53

** server can't find hello-john.test: NXDOMAIN

如果我关闭 Wi-Fi,我只会看到解析器#1scutil --dns显示为

DNS configuration

resolver #1
  flags    : 
  reach    : 0x00000000 (Not Reachable)

我相信我缺少一些配置,/etc/resolver/test但我找不到方法来确保它被使用。

感谢您的帮助!

答案1

尽管 nslookup 和 dig 没有返回正确的响应,但似乎我仍然可以 ping 主机

ping:

ping hello-john.test

结果:

PING hello-john.test (192.168.99.169): 56 data bytes
64 bytes from 192.168.99.169: icmp_seq=0 ttl=64 time=0.259 ms
64 bytes from 192.168.99.169: icmp_seq=1 ttl=64 time=0.390 ms

这对我的目的来说已经足够好了

相关内容