在 C 中创建自定义 DNS 名称服务器

发布于 2024-08-08 22:25:09 字数 185 浏览 2 评论 0原文

需要使用 C 创建一个自定义 DNS 名称服务器,它将检查 mysql 数据库以查看客户端 IP 是否需要定向到不同的服务器。将其用于测试网络,因此只有在启用了真正的查找的情况下,对 foo.com 的请求才会到达那里,否则请求将被定向到开发环境。有什么建议/推荐吗?

目前正在使用 ldns 或 c-ares 等工具查看 libevent

Need to create a custom DNS name server using C which will check against a mysql db to see if the client IP need to be directed to a different server. Using this for a test network so requests to foo.com will only go there if true lookup is enabled, otherwise requests will be directed to a development env. Any suggestions/recommendations?

Currently looking at libevent with something like ldns or c-ares

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

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

发布评论

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

评论(4

像极了他 2024-08-15 22:25:09

BIND 已经有一个 mySQL 扩展(使用动态可加载区域)。您所需要做的就是创建一个包含翻译的地址表,并定义使用该表构建正确 DNS 记录的查询。

有关完整文档,请参阅:http://bind-dlz.sourceforge.net/

BIND already has a mySQL extension (using dynamic loadable zones). All you need to do is create a table of addresses with translations and define the queries that build the correct DNS records using the table.

For full documentation see: http://bind-dlz.sourceforge.net/

深海不蓝 2024-08-15 22:25:09

与我现在正在做的事情非常相似,除了在我的情况下,我必须让 DNS 服务器返回与正常情况不同的错误消息,以适应它在专用网络上运行的事实。

我决定只下载 BIND 源代码并编写我的修改作为其补丁。然后,为了部署,我们可以下载最新的 BIND 源,其中包含新的安全补丁,应用我们的自定义补丁并构建它。

我建议您做同样的事情,只需获取 BIND 并根据需要进行修改即可。您可以在 ISC.ORG 获取 BIND 及其所有文档。

Very similar to something that I am working on right now, except in my case I have to make the DNS server return different error messages than normal to accommodate for the fact that it runs on a private network.

I decided to just download BIND source code and write my modifications as a patch to that. Then for deployment, we can download the latest BIND source, which will include new security patches, apply our customisation patch, and build it.

I recommend that you do much the same thing, just get BIND and modify it as needed. You can get BIND and all its documentation here at ISC.ORG.

伴我老 2024-08-15 22:25:09

Bob,我已经编写了 ldnslibevent 的混搭,它应该为您提供一个良好的开端,让您能够准确地完成您想要的操作。

请查看 http://code.google.com/p/evldns/

Bob, I've already written a mash-up of ldns and libevent which should provide you with a good start to be able to do exactly what you want.

Have a look at http://code.google.com/p/evldns/

情魔剑神 2024-08-15 22:25:09

我最终选择了 libevent 1.4,它包含自己的处理 dns 请求的函数。 libevent 包含的 evdns 函数非常简单,正是我创建自定义 dns 服务器所需要的。我考虑过使用bind,但不想处理必须设置区域和额外配置的问题,evdns 允许我使用现有的 resolv.conf 将任何 dns 请求转发到实名服务器,并根据需要根据信息修改响应包含在 mysql 表中。

I ended up going with libevent 1.4 which contains its own functions for dealing with dns requests. The evdns functions that libevent contains are pretty straight forward and where exactly what i needed to create q custom dns server. I looked at using bind, but didnt want to deal with having to set up zones and extra configuration, evdns allowed me to use the existing resolv.conf to forward any dns requests to real name servers and to modify the responses as needed based on information contained in a mysql table.

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