我可以嘗試使用GetAddrInfo
解決ipv6.google.com
:的getaddrinfo無法解決ipv6.google.com(但NSLOOKUP可以)
wsaError = getaddrinfo("ipv6.google.com", null, null, ref addrInfo);
返回套接字錯誤代碼是11001
(沒有這樣的主機是已知的)。
Note: The deprecated legacy function
GetHostByName
does not support IPv6. It has been replaced withGetAddrInfo
.
但奇怪的是,我可以使用nslookup
,它可以找到的地址就好了:
問題
SendRequest(), len 33
HEADER:
opcode = QUERY, id = 4, rcode = NOERROR
header flags: query, want recursion
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
ipv6.google.com, type = A, class = IN
權威答案
Got answer (106 bytes):
HEADER:
opcode = QUERY, id = 4, rcode = NOERROR
header flags: response, want recursion, recursion avail.
questions = 1, answers = 1, authority records = 1, additional = 0
QUESTIONS:
ipv6.google.com, type = A, class = IN
ANSWERS:
-> ipv6.google.com
type = CNAME, class = IN, dlen = 9
canonical name = ipv6.l.google.com
ttl = 21743 (6 hours 2 mins 23 secs)
AUTHORITY RECORDS:
-> l.google.com
type = SOA, class = IN, dlen = 38
ttl = 30 (30 secs)
primary name server = ns4.google.com
responsible mail addr = dns-admin.google.com
serial = 1486713
refresh = 900 (15 mins)
retry = 900 (15 mins)
expire = 1800 (30 mins)
default TTL = 60 (1 min)
非權威的問題
SendRequest(), len 33
HEADER:
opcode = QUERY, id = 5, rcode = NOERROR
header flags: query, want recursion
questions = 1, answers = 0, authority records = 0, additional = 0
QUESTIONS:
ipv6.google.com, type = AAAA, class = IN
非權威的答案
Got answer (82 bytes):
HEADER:
opcode = QUERY, id = 5, rcode = NOERROR
header flags: response, want recursion, recursion avail.
questions = 1, answers = 2, authority records = 0, additional = 0
QUESTIONS:
ipv6.google.com, type = AAAA, class = IN
ANSWERS:
-> ipv6.google.com
type = CNAME, class = IN, dlen = 9
canonical name = ipv6.l.google.com
ttl = 21743 (6 hours 2 mins 23 secs)
-> ipv6.l.google.com
type = AAAA, class = IN, dlen = 16
AAAA IPv6 address = 2607:f8b0:4009:801::1012
ttl = 270 (4 mins 30 secs)
------------
Name: ipv6.l.google.com
Address: 2607:f8b0:4009:801::1012
Aliases: ipv6.google.com
什麼能導致nslookup
能夠當GetAddrInfo
無法解析地址?我能做些什麼與GetAddrInfo
有什麼不同,所以它的工作原理?
的讓我解決'ipv6.google。 com',但後來'stackoverflow.com'不能解決。我仍然需要解決nslookup如何管理它的問題。 –
我想出了* nslookup如何完成它的任務。它運行一個'A'查詢,然後分別進行'AAAA'查找。所以我*有*調用'getaddrinfo'兩次,一次用於IPv6,然後再用於IPv4。 –
嘗試將'hints.ai_family'設置爲'AF_UNSPEC',以允許'getaddrinfo()'同時查詢IPv4和IPv6信息。 –