I am facing a problem with JVM and DNS.
Everything I'm reading (including the docs and this) says that I can disable JVM DNS caching using networkaddress.cache.ttl, which can be set using java.security.Security.setProperties, but through the standard approach of using system properties. I have successfully changed this to 0, so no more caching in my JVM.
But now, on each call of InetAddress.getByName("mytest.com"), it seems that my JVM is using the system DNS cache (in my case Windows 8). Indeed, between 2 calls of the method, I have changed the BIND9 properties for "mytest.com", but the IP return is still the same. Here is the workflow:
setCachePolicyInJVM(0)in my Java code.- set 
mytest.comto 192.168.1.188 in BIND9, restart. InetAddress.getByName("mytest.com").getHostAddress();-> 192.168.1.188- set 
mytest.com-> 192.168.1.160 in BIND9, restart. InetAddress.getByName("mytest.com").getHostAddress();-> 192.168.1.188 (should be 160 if there was no caching).- Flush the Windows DNS
 InetAddress.getByName("mytest.com").getHostAddress();-> 192.168.1.160
I have read several times that the JVM does not use the system cache, but that is wrong: it clearly does.
How do we force a new DNS resolution on each call, bypassing the OS DNS cache?