title: JVM and OS DNS Caching
body: <p>I am facing a problem with JVM and DNS.</p>
  
  <p>Everything I'm reading (including <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/net/properties.html">the docs</a> and <a href="http://www.verisigninc.com/assets/stellent/030957.pdf">this</a>) says that I can disable JVM DNS caching using <code>networkaddress.cache.ttl</code>, which can be set using <code>java.security.Security.setProperties</code>, but through the standard approach of using system properties. I have successfully changed this to 0, so no more caching in my JVM.</p>
  
  <p>But now, on each call of <code>InetAddress.getByName("mytest.com")</code>, it seems that my JVM is using the <em>system</em> 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:</p>
  
  <ol>
  <li><code>setCachePolicyInJVM(0)</code> in my Java code.</li>
  <li>set <code>mytest.com</code> to 192.168.1.<em>188</em> in BIND9, restart.</li>
  <li><code>InetAddress.getByName("mytest.com").getHostAddress();</code> -> 192.168.1.<em>188</em></li>
  <li>set <code>mytest.com</code> -> 192.168.1.<em>160</em> in BIND9, restart.</li>
  <li><code>InetAddress.getByName("mytest.com").getHostAddress();</code> -> 192.168.1.<em>188</em> (should be <em>160</em> if there was no caching).</li>
  <li>Flush the Windows DNS</li>
  <li><code>InetAddress.getByName("mytest.com").getHostAddress();</code> -> 192.168.1.<em>160</em></li>
  </ol>
  
  <p>I have read several times that the JVM does not use the system cache, but that is wrong: it clearly does.</p>
  
  <p>How do we force a new DNS resolution on each call, bypassing the <em>OS</em> DNS cache?</p>