为什么java无法解析Map到ipv6地址的fqdn地址?

u0njafvf  于 2021-06-27  发布在  Java
关注(0)|答案(0)|浏览(457)

我正在尝试一个简单的程序,它将fqdn/hostname作为输入并返回Map到在dns服务器上配置的fqdn的ipv6地址

try {
            InetAddress add= InetAddress.getByName("SCP1.xyz.com");
                System.out.println(add);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

fqdn是在dns中配置的,我可以在tcpdump中看到来自dns的响应,包括ipv6Map。并返回具有正确ipv6Map的响应:

;; ANSWER SECTION:
SCP1.xyz.com.         86400   IN      AAAA    2a00:8a00:4000:65ef:ffff:ffff:ffff:b58c

但java未能返回ipv6地址并抛出java.net.unknownhostexception:

java.net.UnknownHostException: No such host is known (SCP1.xyz.com)
    at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
    at java.base/java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1515)
    at java.base/java.net.InetAddress$NameServiceAddresses.get(InetAddress.java:848)
    at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1505)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1364)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1298)
    at java.base/java.net.InetAddress.getByName(InetAddress.java:1248)
    at mypack.ResolutionTest.main(ResolutionTest.java:26)

当fqdnMap到ipv4时,同样的代码也可以正常工作。我尝试设置-dsun.net.spi.nameservice.provider.1=dns,sun,但没有任何改进。
注意:在linux和windows中行为是相同的
我是新来的,所以会感谢任何帮助。谢谢。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题