JVM and OS DNS Caching

前端 未结 3 647
你的背包
你的背包 2021-02-07 20:16

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.tt

3条回答
  •  感情败类
    2021-02-07 21:15

    You can either edit your $JAVA_HOME/jre/lib/security/java.security for Java 6-8 and $JAVA_HOME/conf/security/java.security property file to add the following property .

    networkaddress.cache.ttl=1
    

    It is not available to set it in command line.

    Since these 2 properties are part of the security policy, they are not set by either the -D option or the System.setProperty() API, instead they are set as security properties.

    To set this property inside the code, you can use the following method.

    java.security.Security.setProperty("networkaddress.cache.ttl", "1")
    

    Or add the following property in the java command line.

    -Dnetworkaddress.cache.ttl=1
    

    It is also important to note that values are effective only if the corresponding networkaddress.cache.* properties are not set.

    See Java 8 Networking Properties, Java 9 Networking Properties and VeriSign DNS Caching in Java Virtual Machines for more details.

    This answer also adds some details.

提交回复
热议问题