我刚刚在本地安装了 SkyDNS,但我没有从节点的 dns 查找中解析 IP 地址。我的 resolv.conf 只有一个条目:
nameserver 127.0.0.1
挖掘的结果:
$ dig service.skydns.local
; <<>> DiG 9.9.5-3ubuntu0.8-Ubuntu <<>> service.skydns.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25842
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;service.skydns.local. IN A
;; ANSWER SECTION:
service.skydns.local. 3600 IN A 10.0.1.125
;; Query time: 1 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Mar 16 10:41:21 BRT 2016
;; MSG SIZE rcvd: 54
当我尝试使用 Node 的 dns 查找解决时:
var dns = require('dns');
dns.lookup('service.skydns.local', function(err, res, fam){console.log(err, res, fam);})
{ [Error: getaddrinfo ENOTFOUND service.skydns.local]
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'service.skydns.local' } undefined undefined
使用resolve4而不是lookup它可以工作,但是为什么lookup不能从本地dns解析这个地址呢?