Recently I was in the position of having to override the system default DNS server configuration with a custom DNS server for a Java app. Expecting this to be easily achievable along the line of the well-known http.proxyHost/http.proxyPort JVM parameters I whipped out Google.
Turned out to not to be so simple.
Obviously I got some search hits, but no simple recipe for the simple configuration change I was looking for. After spending some time with the leads I was able to conclude that, as a consequence of an apparent exemple of over-engineering by Sun, the following is explicitly required just to change the JVM DNS server:
//Override system DNS setting with Google free DNS server System.setProperty("sun.net.spi.nameservice.nameservers", "22.214.171.124"); System.setProperty("sun.net.spi.nameservice.provider.1", "dns,sun");
This will set DNS settings for JVM. I will try to see if it can help run DNS config of a system (windows). How about apn, ip and wins settings? I reckon the codes must be similar…