
IP 192.168.99.169를 사용하는 가상 머신의 호스트에서 DNS 서버가 실행되고 있습니다.
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 서버에서는 모든 것이 올바르게 작동합니다. 유일한 DNS 서버가 192.168.99.169가 되도록 Mac에서 DNS 서버를 업데이트하면 작업도 동일한 방식으로 작동하지만 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
검색할 IP 주소가 여러 개 필요하므로 DNS 서버를 완전히 재정의하는 것은 나에게 적합하지 않습니다.
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를 끄면 리졸버 #1이 scutil --dns
다음과 같이 표시 됩니다.
DNS configuration
resolver #1
flags :
reach : 0x00000000 (Not Reachable)
일부 구성이 누락된 것 같지만 /etc/resolver/test
이를 확실히 사용할 수 있는 방법을 찾을 수 없습니다.
당신의 도움을 주셔서 감사합니다!
답변1
nslookup 및 dig가 올바른 응답을 반환하지 않더라도 여전히 호스트에 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
이것은 내 목적에 충분히 효과적입니다.