简体   繁体   English

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

[英]Create custom DNS name server in C

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. 需要使用C创建自定义DNS名称服务器,该服务器将检查mysql数据库以查看是否需要将客户端IP定向到其他服务器。 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. 将其用于测试网络,因此如果启用了真正的查找,对foo.com的请求将仅在那里,否则请求将被定向到开发环境。 Any suggestions/recommendations? 有什么建议/建议吗?

Currently looking at libevent with something like ldns or c-ares 目前正在寻找像ldns或c-ares之类的东西

BIND already has a mySQL extension (using dynamic loadable zones). BIND已经有一个mySQL扩展(使用动态可加载区域)。 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. 您需要做的就是创建一个包含翻译的地址表,并使用该表定义构建正确DNS记录的查询。

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

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. 非常类似于我现在正在处理的事情,除了在我的情况下,我必须让DNS服务器返回不同于正常的错误消息,以适应它在专用网络上运行的事实。

I decided to just download BIND source code and write my modifications as a patch to that. 我决定只下载BIND源代码并将我的修改作为补丁编写。 Then for deployment, we can download the latest BIND source, which will include new security patches, apply our customisation patch, and build it. 然后,为了部署,我们可以下载最新的BIND源,其中包括新的安全补丁,应用我们的自定义补丁,并构建它。

I recommend that you do much the same thing, just get BIND and modify it as needed. 我建议您做同样的事情,只需获取BIND并根据需要进行修改。 You can get BIND and all its documentation here at ISC.ORG . 您可以在ISC.ORG获取BIND及其所有文档。

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. Bob,我已经写过ldnslibevent的混搭,它应该为你提供一个良好的开端,能够做到你想要的。

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

I ended up going with libevent 1.4 which contains its own functions for dealing with dns requests. 我最终选择了libevent 1.4,它包含自己的处理dns请求的函数。 The evdns functions that libevent contains are pretty straight forward and where exactly what i needed to create q custom dns server. libevent包含的evdns函数非常简单,我需要创建q自定义dns服务器。 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. 我看着使用bind,但不想处理必须设置区域和额外配置,evdns允许我使用现有的resolv.conf将任何dns请求转发到实名服务器并根据需要修改响应包含在mysql表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM