问题描述
当使用Dns.GetHostAddresses(fred)时,它只返回IPv4地址作为响应。如何获取IPv6地址?有没有不同的方法我会使用?
Socket.OSSupportsIPv6返回true和IPv6连接工作正常。操作系统是Windows 2008 R2,.NET版本是3.5。
IPv6仍然使用DNS来解析地址,以便这样要工作,您将需要为该域名的区域文件添加一个IPv6条目。我们怀疑如果IPv6不可用,Ping将会回退到IPv4,而不是你一直希望的那样'-6'标志。
When using Dns.GetHostAddresses("fred") it returns only IPv4 addresses in response. How to get the IPv6 addresses as well? Is there different method I shall use?
Socket.OSSupportsIPv6 returns true and IPv6 connections work fine. The OS is Windows 2008 R2, .Net version is 3.5.
IPv6 still uses DNS to resolve addresses so in order for this to work you will need to add an IPv6 entry to your zone file for this domain name. It'll then resolve properly.
I suspect that Ping will fall back to IPv4 if an IPv6 is not available, not exactly what you'd hope once you've specified the '-6' flag.
这篇关于GetHostAddress()不返回IPv6,只能返回IPv4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!