Once an application has performed network access (i.e. urlconnection, parsing of xml document with external references, etc), the DNS settings get cached so any subsequent operation will use the old settings even if the real settings have changed. To reset everything, you have to restart the server since the the default setting JVM setting is to cache forever.

There are 4 properties that can be used to override the default behaviour.

networkaddress.cache.ttl (default: -1)
Specified in java.security to indicate 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". networkaddress.cache.negative.ttl (default: 10)
Specified in java.security to indicate 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". sun.net.inetaddr.ttl
This is a sun private system property which corresponds to networkaddress.cache.ttl.
It takes the same value and has the same meaning, but can be set as a command-line
option. However, the preferred way is to use the security property mentioned above. sun.net.inetaddr.negative.ttl
This is a sun private system property which corresponds to networkaddress.cache.negative.ttl.
It takes the same value and has the same meaning, but can be set as a command-line option.
However, the preferred way is to use the security property mentioned above.

So you can disable caching by adding -Dsun.net.inetaddr.ttl=0 on the command line starting the JVM. But you can't set the value of networkaddress.cache.ttl on the command line. You can set the required value in the java.security file located in %JRE%\lib\security

networkaddress.cache.ttl=60
networkaddress.cache.negative.ttl=10

or set the value in your code with

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

禁用Java DNS缓存-Disable DNS caching的更多相关文章

  1. 浏览器 DNS缓存与DNS prefetch (DNS预解析)

    浏览器 DNS缓存 浏览器DNS缓存的时间跟DNS服务器返回的TTL值无关. 注:TTL(Time-To-Live),就是一条域名解析记录在DNS服务器中的存留时间. 浏览器在获取网站域名的实际IP地 ...

  2. Linux在shell终端中清空DNS缓存,刷新DNS的方法

    现在很多Linux发行版都没有内置DNS本地缓存,Linux不像Windows那样可以使用ipconfig /flushdns来刷新,在Linux下无需刷新,因为本身没有缓存. 前言 在Linux系统 ...

  3. 域名解析的DNS缓存如何清理

    域名解析(DNS)缓存是什么? 域名解析缓存又名DNS缓存,常见表现名称是TTL:(TimeToLive)生存时间,就是域名解析记录在DNS服务器中的存留有效时间. 当各地的DNS服务器接受到解析请求 ...

  4. Linux设置DNS地址及清理DNS缓存方法

    1.设置DNS地址 编辑vim /etc/resolv.conf 文件. 增加DNS地址:nameserver ip. 2.清理DNS缓存 清理dns缓存: 通过重启nscd服务来达到清理dns缓存的 ...

  5. 清理dns缓存

    dns缓存是什么? DNS缓存指DNS返回了正确的IP之后,系统就会将这个结果临时储存起来.并且它会为缓存设定一个失效时间 (例如N小时),在这N小时之内,当你再次访问这个网站时,系统就会直接从你电脑 ...

  6. windows查看与清理dns缓存

    1.windows下在命令行输入  ipconfig /flushdns 清理本地dns缓存查看dns缓存   ipconfig/displaydns2.Mac OSX下在命令行输入  lookupd ...

  7. 通过JAVA反射修改JDK1.6*当中DNS缓存内容

    时间 2012-05-28 17:09:03  Taobao QA Team原文  http://qa.taobao.com/?p=15523 为了实现性能压测时的域名动态绑定功能,尝试通过java反 ...

  8. Java 内存级默认DNS缓存

    Java 默认的DNS缓存时间,即不设置任一系统属性,如networkaddress.cache.ttl 设置SecurityManager 默认的CachePolicy为Forever,即永久缓存D ...

  9. 浏览器的DNS缓存

    通过设置hosts文件可以强制指定域名对应的IP,当修改hosts文件,想要浏览器生效,最直接的方法关闭浏览器后重新开启:如果不想重启浏览器,只需要清空浏览器的DNS缓存即可.清空DNS缓存在chro ...

随机推荐

  1. WCF:System.Security.Cryptography.CryptographicException: 密钥集不存在

    WCF使用IIS部署时,使用x509证书验证,在创建证书并正确配置程序后,访问出现错误提示: System.Security.Cryptography.CryptographicException: ...

  2. 关于Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY

    google 给的android的例子里,有用到google APIs,新版本的ADT默认只有Android的SDK,如果运行平台与目标平台不一致会报:Installation error: INST ...

  3. matlab GUI之常用对话框(三)-- dialog \ errordlg \ warndlg \ helpdlg \ msgbox \questdlg

    常用的对话框(三) 1.普通对话框  dialog 调用格式: h=dialog('PropertyName','PropertyValue'......) %普通对话框 h=dialog( ]); ...

  4. jquery $.post 返回json数据

    $(function () { $("#prompt").hide(); $("#searchIpt").keyup(function () { var key ...

  5. linux grep 指定字符串的正则表达式

    cat all_uuid_log | grep "[a-z0-9]\{32\}"

  6. 为IE6-7间接支持:before和:after伪类

    :before和:after我们经常会用到,特别是在做移动端页面时,利用它制作文字前后的ICON.图片的垂直居中之类的非常方便且代码简洁(当然,功能远比这些要多的多...). 可是在PC端,由于现在还 ...

  7. 通过class实例取得类的接口,父类,构造器

    interface China {     public static final String NATIONAL = "JAPAN";     public static fin ...

  8. 转载[WampServer下使用多端口访问]

    作者:韩子迟 原文链接:http://www.cnblogs.com/zichi/p/4589142.html 注意点:www和www2都需要安装服务: 在C:\wamp\bin\apache\Apa ...

  9. java中对于JSON 的处理 fastjson gson 系统自带的JSON 的选择

    从2月初到8月末,经历了一段痛苦的经历,现在总算感觉已经走出来了,经历那事之后 感觉对人与人之间的感情看的更透了,人也没那么浮躁了: 说实话 以前从来不知道鸟叫有多好听,现在突然觉的大自然真的很美,放 ...

  10. linux之awk

    相较于sed 常常作用于一整个行的处理,awk 则比较倾向于一行当中分成数个『字段』来处理. 因此,awk 相当的适合处理小型的数据数据处理呢! awk 通常运作的模式是这样的: [root@linu ...