用Java替代默认的DNS名称解析 [英] Replace default DNS name resolution in Java
问题描述
我想更改JVM在HttpURLConnections中解析域名的方式。
而不是通过默认TCP / IP堆栈去DNS服务器,我想写我自己的代码来解决域名。
有没有办法来替换默认名称解析机制?
我不知道是否可以工作,但有系统属性
System.setProperty(sun.net.spi .nameservice.nameservers,localhost);
System.setProperty(sun.net.spi.nameservice.provider.1,dns,sun);
也许如果你有你的java应用程序在dns端口上打开一个端口(53),并自动处理请求。
当然,如果当前机器上已经有一个dns服务器, p>
I'd like to change the way the JVM resolves domain names in HttpURLConnections.
Instead of going to DNS servers through the default TCP/IP stack I wanted to write my own code to resolve domain names.
Is there a way to replace the default name resolution mechanism?
i have no idea if it would work, but there are system properties
System.setProperty("sun.net.spi.nameservice.nameservers", localhost); System.setProperty("sun.net.spi.nameservice.provider.1", "dns,sun");
perhaps if you have your java application open a port on the dns port (53) and process requests yourself.
Of course this falls down if there is a dns server already on the current machine.
这篇关于用Java替代默认的DNS名称解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!