一个简单的 DNS 服务器

发布于 2024-08-09 02:25:13 字数 118 浏览 4 评论 0原文

我必须用 C 语言实现一个 DNS 服务器,但我不知道从哪里开始。 DNS 具有哪些功能...我如何在单个 C 文件中实现简单的 DNS。

我什至不想使用数据库,只需一个文件即可。

先感谢您

I have to implement a DNS server in C and I don't know where to start. What are all the features that a DNS has...how can I implement a bare-bones DNS in single C file.

I don't even want to use a Database, just a file will work.

Thank you in advance

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

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

发布评论

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

评论(5

原来是傀儡 2024-08-16 02:25:13

这对于家庭作业来说太重要了!你的老师很有野心。实施 DNS
需要阅读至少 10 个复杂的 RFC(更不用说 DNSSEC...)
将自己限制在 RFC 1034 和 1035 中,有强制
RFC之后(例如2181和2671)。请参阅其中的漂亮图表

它是权威名称服务器还是递归名称服务器?

必须从头开始做吗?如果没有,我强烈建议开始
使用 evldns 库,它允许您编写
200 行 C 语言中的 anthoritative 名称服务器。

否则,通常的建议适用:阅读源代码(我建议
nsd 用于权威服务器和 未绑定 用于递归
一)。

That's big for homework! Your teacher is ambitious. Implementing DNS
requires reading at least ten complicated RFC (not mentioning DNSSEC...) Do
not limit yourself to RFC 1034 and 1035, there are mandatory
RFC after (such as 2181 and 2671). See a nice graph of them.

Is it an authoritative name server or a recursive one?

Do you have to do it from scratch? If not, I strongly suggest to start
with the evldns library, which allows you to write an
anthoritative name server in 200 lines of C.

Otherwise, the usual advice applies: read source code (I suggest
nsd for an authoritative server and unbound for a recursive
one).

意中人 2024-08-16 02:25:13

DNS 是一个大规范。如果您确实需要 DNS,请使用 DNS 服务器。因此,如果您想要一些非常快速和肮脏的东西,为什么不编写一个编辑主机文件的程序(C:\windows\system32\drivers\etc\hosts 或 /etc/hosts(在 UNIX 上)?)

DNS is a big spec. If you really want DNS, use a DNS server. So if you want something really quick and dirty, why not just write a program that edits your hosts file (C:\windows\system32\drivers\etc\hosts or /etc/hosts (on UNIX)?)

小…红帽 2024-08-16 02:25:13

这应该可以帮助您开始。

此示例使用 BSD 套接字构建一个简单的 DNS 解析器。
http://www. binarytides.com/blog/dns-query-code-in-c-with-winsock-and-linux-sockets/

This should get you started.

This example uses BSD sockets to build a simple DNS resolver.
http://www.binarytides.com/blog/dns-query-code-in-c-with-winsock-and-linux-sockets/

深海夜未眠 2024-08-16 02:25:13

dns.net points up RFC 1034: DOMAIN NAMES - CONCEPTS AND FACILITIES and RFC 1035: DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION as the definitive references.

As a topical plus, wow your teacher by including some non-ascii IDN names in your toy lookup list.

话少情深 2024-08-16 02:25:13

可以在此处找到该协议所基于的 RFC:http://www.zoneedit.com/ doc/rfc/

在互联网上还可以找到一些对该协议有用的解释,例如:http://www.windowsnetworking.com/articles_tutorials/Understanding-DNS-Protocol-Part1.html

The RFCs that the protocol is based on can be found here: http://www.zoneedit.com/doc/rfc/

There are also several explanations of the protocol that should be useful to be found around the internet, such as this one: http://www.windowsnetworking.com/articles_tutorials/Understanding-DNS-Protocol-Part1.html

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