Replace default DNS resolution in Java

I would like to change the way the JVM resolves domain names in HttpURLConnections.

Instead of switching to DNS servers via 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?

+3
source share
2 answers

I don't know if this will 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 a Java application that opens a port on the dns (53) port and processes the requests yourself.

, , DNS-.

+2

URL-, IP-, Host HttpUrlConnection.

http://www.myserver.com/foo.html

http://192.168.1.100/foo.html
Host: www.myserver.com

dnsjava DNS API Java.

+1

All Articles