执行直接 DNS 查找的代码

发布于 2024-07-20 15:52:04 字数 237 浏览 2 评论 0原文

我正在考虑进行一项实验,以不同的方式跟踪 DNS 值(例如它们更改的频率等等)。 为此,我需要能够直接向服务器发出 DNS 请求,以便 1) 我知道它来自哪个服务器,2) 我可以请求来自多个服务器的响应,3) 我可以避免本地操作系统运行缓存。

有谁知道有一个库(按优先顺序是 c#、D、C、C++)可以让我直接查询 DNS 服务器吗? 如果不行,有谁知道一个易于理解的描述我可以通过哪个 DNS 协议来实现这样的系统?

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

苏璃陌 2024-07-27 15:52:04

我只有 C 语言的经验,所以这是我的列表:

  • libresolv 是旧的、传统的和标准的方法。 它在每个 Unix 上都可用(类型 man 3 解析器),并包括类似的例程
    res_query 或多或少可以满足您的需求。 要查询特定的名称服务器,您通常会更新全局变量 _res.nsaddr_list (请注意,显然,它不适用于 IPv6)。

  • ldns 是现代而闪亮的解决方案。 您有优秀的在线文档

  • 一个非常常见的库,但显然没有维护,是 adns .

I have experience only with C, so here is my list:

  • libresolv is the old, traditional and standard way. It is available on every Unix (type man 3 resolver) and includes routines like
    res_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.

  • a very common library, but apparently unmaintained, is adns.

厌倦 2024-07-27 15:52:04

对于 C,我会选择 http://cr.yp.to/djbdns/ Blub/library.html (如果您需要完全控制,则为低级部分,即 dns_transmit* 和朋友)——对于 C#,可能是 http://www.c-sharpcorner.com/UploadFile/ivxivx/DNSClient12122005234612PM/DNSClient.aspx (现在无法测试那个,因此“也许”!)。

For C, I'd go with http://cr.yp.to/djbdns/blurb/library.html (the low-level parts if you need total control, i.e. dns_transmit* and friends) -- for C#, maybe http://www.c-sharpcorner.com/UploadFile/ivxivx/DNSClient12122005234612PM/DNSClient.aspx (can't test that one right now, whence the "maybe"!).

幽蝶幻影 2024-07-27 15:52:04

DNS 规范分布在许多RFC(请参阅漂亮的图表),我强烈建议不要< /strong> 从头开始​​实现存根解析器。 有很多机会会出错。 DNS 在过去几年中发展了很多。 如果你勇敢而疯狂,这里有最重要的 RFC:

  • RFC 1034,概念
  • RFC 1035,格式
  • RFC 2181,更新规范,修复许多错误或歧义
  • RFC 2671,EDNS(今天强制)
  • RFC 3597,处理未知资源记录类型
  • 和许多其他......

The DNS specification is spread over many RFC (see a nice graph) and I would strongly advise not to implement a stub resolver from scratch. There are many opportunities to get it wrong. The DNS evolved a lot in the last years. If you are brave and crazy, here are the most important RFC:

  • RFC 1034, concepts
  • RFC 1035, format
  • RFC 2181, update to the specification, to fix many errors or ambiguities
  • RFC 2671, EDNS (mandatory today)
  • RFC 3597, handling the unknown resource record types
  • and many others...
流星番茄 2024-07-27 15:52:04

libdns(我认为它是绑定的一部分)。 有一个 cygwin 端口可能对 Windows 环境有用。

http://rpm2html.osmirror.nl/libdns.so.21.html

libdns (I think it's part of bind). There's a cygwin port which may be useful for windows environments.

http://rpm2html.osmirror.nl/libdns.so.21.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文