检索 DNS 缓存中的内容 [英] Retrieving what's in the DNS cache

查看:32
本文介绍了检索 DNS 缓存中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 中,是否有 API 来检索 DNS 缓存的内容.我的一所大学问了我这个问题,但到目前为止我已经在 MSDN 上查看并搜索了网络,但我找不到任何关于此的信息.他目前的解决方案是解析 ipconfig/displaydns 的输出,但我确信有更好的方法来做到这一点.ipconfig 如何读取缓存中的内容?

In Windows, is there an API to retrieve the content of the DNS cache. A college of mine asked me this very question but so far I've looked in on MSDN and searched the web but I couldn't find any information on this. His current solution for this is to parse the output of ipconfig /displaydns but I'm sure there is a better way to do it. How does ipconfig reads what's in the cache anyway?

推荐答案

DnsQuery 函数,使用 DNS_QUERY_NO_WIRE_QUERY 调用> 查询选项,允许您在缓存中查找特定条目.这可能就足够了,这取决于您究竟要做什么.似乎没有任何记录的枚举条目的方法.

The DnsQuery function, called with the DNS_QUERY_NO_WIRE_QUERY query option, allows you to look up a specific entry in the cache. This may be sufficient, depending on what exactly you're trying to do. There doesn't appear to be any documented way of enumerating the entries.

查看 ipconfig.exe,它似乎使用了几个未公开的函数,尤其是 DnsGetCacheDataTable.对此函数名称的 Google 搜索生成了此代码,这似乎有效,只是需要一行更正;将 typedef 更改为:

Looking at ipconfig.exe it seems it uses several undocumented functions, in particular DnsGetCacheDataTable. A Google Search on this function name produced this code which seems to work, except that one line needs to be corrected; change the typedef to:

typedef int(WINAPI *DNS_GET_CACHE_DATA_TABLE)(PDNSCACHEENTRY);

这篇关于检索 DNS 缓存中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆