Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flushing linux DNS from JAVA

Tags:

linux

dns

cloud

We have a RC module that gets dropped into our cloud servers during hot deployment. To that end, I need a way to flush the DNS programmatically from within JAVA. The best solution that I can think of is to just have java fire an external shell script, however I'm not having any luck. I've tried the "normal" procedures to an avail:

1) restarting nscd service (not installed in these servers)
2) /etc/init.d/networking restart (no effect)
3) /etc/init.d/dns-clean start (no effect)

Anyone have any more suggestions?

(NOTE: this is a re-word of a previous post that must have been determined as being "non-development" related...)

TIA

like image 954
mjk Avatar asked Jan 26 '26 19:01

mjk


1 Answers

This is JVM implementation dependent. On Oracle JDK, you need to set the networkaddress.cache.ttl and networkaddress.cache.negative.ttl security properties (in $JAVA_HOME/lib/security/java.security). The factory default is to cache positive answers forever.

AFAIK there is no way to flush the cache at runtime.

See http://docs.oracle.com/javase/7/docs/technotes/guides/net/properties.html

like image 91
Wil Tan Avatar answered Jan 28 '26 10:01

Wil Tan