Search code examples
javaelasticsearchttl

Best way to set "networkaddress.cache.ttl"


I need to set the Java setting networkaddress.cache.ttl. I know very little about Java so I'm asking, what is Best Practice for setting this value?

I know that the setting lives in $JAVA_HOME/jre/lib/security/java.security but customizing this file doesn't seem very excellent. Is there a place for custom Java settings?

This is for Elasticsearch, so if I could glom it into the ES init script or something, that would be better, but I don't know how to set this on-the-fly.

Thanks in advance Java people!


Solution

  • if you don't want to set security properties file then you can set sun.net.inetaddr.ttl property on the JVM command line with -Dsun.net.inetaddr.ttl=0.

    However, the preferred way is to use the security properties file (ref:Oracle documentation) because sun.net.inetaddr.ttl may not be supported in future releases.