进行直接 DNS 查找的代码 [英] Code to do a direct DNS lookup
问题描述
我正在考虑进行一项实验,以不同的方式跟踪 DNS 值(例如它们更改的频率等等).为此,我需要能够直接向服务器发出 DNS 请求,以便 1) 我知道它来自哪个服务器,2) 我可以请求来自多个服务器的响应以及 3) 我可以避免本地操作系统运行缓存.
I'm thinking of running an experiment to track DNS values in different ways (like how often they change and whatnot). To do this I will need to be able to make a DNS request directly to a server so that 1) I known what server it came from, 2) I can request responses from several servers and 3) I can avoid the local OS run cache.
有谁知道可以让我直接查询 DNS 服务器的库(按优先顺序排列的 c#、D、C、C++)?了解我可以从中实现这样一个系统的 DNS 协议的描述吗?
Does anyone know of a library (c#, D, C, C++ in that order of preference) that will let me directly query a DNS server? Failing that, does anyone know of a easy to understand description of the DNS protocol that I could implement such a system from?
推荐答案
我只用过 C,所以这是我的清单:
I have experience only with C, so here is my list:
libresolv 是旧的、传统的和标准的方法.它在每个 Unix 上都可用(类型
man 3 resolver
)并且包括像这样的例程res_query
或多或少做你想要的.要查询特定的名称服务器,您通常会更新全局变量_res.nsaddr_list
(请注意,显然,它 不适用于 IPv6).
libresolv is the old, traditional and standard way. It is available on every Unix (type
man 3 resolver
) and includes routines likeres_query
which does more or less what you want. To query a specific name server, you typically update the global variable_res.nsaddr_list
(do note that, apparently, it does not work with IPv6).
ldns is the modern and shiny solution. You have good documentation online.
一个非常常见但显然没有维护的库是adns.
a very common library, but apparently unmaintained, is adns.
这篇关于进行直接 DNS 查找的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!