DNS Caching Persistence Tomcat
$2-7 USD
Paid on delivery
I am using Tomcat 3.2.3, APACHE, and JRE 1.3.02. I need to get the IP address for a resource who is using DHCP and the address changes every day at about 4:30. I have the DNS name.
I am doing the following to get the IP address:
InetAddress IAddress = null;
IAddress = [url removed, login to view](address);
String newAddress = [url removed, login to view]();
This always gets the old address. Now, I understand there is a parameter: [url removed, login to view] which controls how long successful name resolutions are saved. This is the documentation on that:
InetAddress Caching
The InetAddress class has a cache to store successful as well as unsuccessful host name resolutions. The positive caching is there to guard against DNS spoofing attacks; while the negative caching is used to improve performance.
By default, the result of positive host name resolutions are cached forever, because there is no general rule to decide when it is safe to remove cache entries. The result of unsuccessful host name resolution is cached for a very short period of time (10 seconds) to improve performance.
Two Java security properties control the TTL values used for positive and negative host name resolution caching:
[url removed, login to view] (default: -1) Indicates the caching policy for successful name lookups from the name service. The value is specified as as integer to indicate the number of seconds to cache the successful lookup. A value of -1 indicates "cache forever".
[url removed, login to view] (default: 10)
Indicates the caching policy for un-successful name lookups from the name service. The value is specified as as integer to indicate the number of seconds to cache the failure for un-successful lookups. A value of 0 indicates "never cache". A value of -1
indicates "cache forever".
In my servlet, I have done the following:
[url removed, login to view]("[url removed, login to view]","0");
String NetCache = [url removed, login to view]
("[url removed, login to view]");
I printed out the results of NetCache & the result was 0 as expected. However, when I do the DNS lookup after the IP address changes, I still get the old address.
Is there something else I need to do or are Tomcat or Apache caching the results or objects somewhere?
## Deliverables
1) Complete source code which will work for Java servlets.
2) Complete ownership and distribution copyrights to all work purchased.
## Platform
Windows
Linux
Project ID: #2880578