Create custom DNS name server in C

人走茶凉 提交于 2020-01-01 16:49:49

问题


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


回答1:


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/




回答2:


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.




回答3:


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/




回答4:


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.



来源:https://stackoverflow.com/questions/1614243/create-custom-dns-name-server-in-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!