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.
Construct URLs replacing the hostname with the numeric IP address and then add the Host header manually to the HttpUrlConnection.
http://www.myserver.com/foo.html
Is equivalent to
http://192.168.1.100/foo.html
Host: www.myserver.com
dnsjava gives you more control in resolving DNS names over the standard Java APIs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With