如何在 C/C 中构建自定义简单 DNS 服务器

发布于 2024-07-15 01:35:01 字数 1709 浏览 8 评论 0原文

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

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

发布评论

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

评论(6

浴红衣 2024-07-22 01:35:01

我在 BSD 许可证下为工作面试编写了一个基本的 DNS 服务器。

可能有人会发现它有用:

https://github.com/nephewtom/dns-server

I wrote a basic DNS server for a job interview under BSD license.

May be someone could find it useful:

https://github.com/nephewtom/dns-server

仅冇旳回忆 2024-07-22 01:35:01

不存在“简单”的缓存 DNS 服务器这样的东西,特别是如果您想要良好的安全性的话。 最近的 DNS 攻击表明,递归 DNS 服务器中的缓存功能特别容易受到攻击。

重新评估您是否确实需要自己的本地缓存。 如果不这样做,您最好修改现有的 DNS 代理代码(例如“dnsmasq”)。

如果您确实想自行开发,可以使用一些不错的库,例如 ldns 可以提供对底层DNS数据包的访问。

我自己将 ldns 与 libevent 结合使用来实现我在之前的问题中提到的模糊 DNS 服务器。

There's no such thing as a "simple" cacheing DNS server, particularly if you want decent security. Recent DNS attacks have shown that the cacheing function in recursive DNS servers is particularly vulnerable.

Re-evaluate whether you actually need local cacheing of your own. If you don't, you're probably better off modifying existing DNS proxy code (such as 'dnsmasq').

If you do want to roll-your-own, there are good libraries such as ldns which can provide the access to the underlying DNS packets.

I'm using ldns myself in conjunction with libevent to implement the Fuzzing DNS server I mentioned in an earlier question.

甜嗑 2024-07-22 01:35:01

有许多 DNS 的免费软件实现。 你可以看看他们的源代码。 例如:

本书 DNS 和 BIND 可能会有所帮助。 当然,还有指定 DNS 的 RFC,请参阅 http://rfc-editor.org/

There are a bunch of free software implementations of DNS. You could look at their source code. For example:

The book DNS and BIND might be helpful. And, of course, there are the RFCs that specify DNS, see http://rfc-editor.org/.

屋檐 2024-07-22 01:35:01

如果您确实需要这样做(这是一项巨大工作,请参阅 Alnitak 的回复),请从现有的程序开始(而不是长期无人维护的单人实验)时间如djbdns)并修改它。

Unbound 可能是一个合理的选择。 (代码库比 BIND 的代码库小。)

If you really need to do that (it is a huge work, see Alnitak's reply), start from an existing good program (not a one-man experiment unmaintained for a long time like djbdns) and modify it.

Unbound is probably a reasonable choice for this. (The code base is smaller than BIND's one.)

深海蓝天 2024-07-22 01:35:01

djbdns 开始。

Start with djbdns.

浪荡不羁 2024-07-22 01:35:01

或者,您可以使用 Ragel 状态机编译器 从头开始​​构建您的服务器。

Alternately, you could use the Ragel State Machine Compiler to build your server from scratch.

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