windows 系统dns client server作用

因为DNS是C/S结构,大家又熟悉DNS server这个概念,所以很容易产生一个误解,认为“DNS Client服务”就是DNS的客户端。误以为如果禁用“DNS Client服务”客户端就不能解析域名了。
产生误解的原因,还在于微软的误导。在Windows的服务管理中,微软声称“DNS Client服务”是“为此计算机解析和缓冲域名系统 (DNS) 名称。如果此服务被停止,计算机将不能解析 DNS 名称并定位 Active Directory 域控制器。如果此服务被禁用,任何明确依赖它的服务将不能启动。”微软这些话是很不负责任的话。
其实,“DNS Client服务”只是客户端对DNS解析内容的缓存服务,禁用“DNS Client服务”并不影响DNS解析,只是客户端不对DNS解析内容进行缓存。命令ipconfig/displaydns 显示本机DNS缓存,但在禁用“DNS Client服务”时失效。
这个服务关闭与否影响并不大,从安全性上考虑,开启它可能泄漏你的缓存内容,确定你曾经访问过的网站。从速度上考虑,关闭它可能会降低反应速度,但一般影响不大。
客户端在遇到一个域名需要解析时,查询顺序为:
1、DNS缓存(如果DNS Client服务启用的话);
2、本机hosts文件;
3、主要DNS server;
4、辅助DNS server。

在修改了本机的hosts文件后,有时需重起一下浏览器才起作用,可能是DNS缓存的原因。
Q:有没有办法可以用命令行清空dns的cache,直接使修改过的hosts文件生效,而不需要重起浏览器?
A:使用命令ipconfig /flushdns 清除本机DNS缓存。
执行ipconfig /flushdns 后若hosts文件仍不起作用,可能需要等待。

其实一种更好的办法就是,开启dns client服务同时设置DNS cache 的时间(或者说dns cache的数量)
A better Win8/7/Vista/XP workaround would be to add two Registry entries to control the amount of time the DNS cache is saved. (KB318803)
  • Flush the existing DNS cache (see above)
  • Start > Run (type) regedit
    Win8 users - from the Charms Bar, select: Search (type) run and select Run (left pane) and (type) "regedit" (no quotes)
  • Navigate to the following location:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters
  • Click Edit > New > DWORD Value (type) MaxCacheTtl
  • Click Edit > New > DWORD Value (type) MaxNegativeCacheTtl
  • Next right-click on the MaxCacheTtl entry (right pane) and select: Modify and change the value to 1
  • The MaxNegativeCacheTtl entry should already have a value of 0 (leave it that way - see screenshot)
  • Close Regedit and reboot ...
  • As usual you should always backup your Registry before editing ... see Regedit Help under "Exporting Registry files"

评论

此博客中的热门博文

mips 精确异常和延时槽

libvirt event 处理

802.11协议用到的简写