Create your own DNS name server in C

You must create your own DNS name server using C, which will check for mysql db to see if the client IP address needs to be redirected to another server. Using this for the test network, therefore, requests to foo.com will only come there if true lookup is enabled, otherwise the requests will be sent to env development. Any suggestions / recommendations?

Currently being considered libevent with something like ldns or c-ares

+3
source share
4 answers

I ended up working with libevent 1.4, which contains its own functions for working with DNS queries. The evdns functions that libevent contains are fairly straightforward and where exactly is what I need to create a q custom DNS server. I looked at using bind, but didn’t want to deal with zone configuration and additional configuration, evdns allowed me to use the existing resolv.conf to forward any DNS queries to real name servers and to change the answers as needed based on the information contained in the mysql table .

+1
source

BIND already has the mySQL extension (using dynamically loaded zones). All you have to do is create an address table 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
source

Bob, I already wrote a mash-up from ldns and libevent , which should give you a good start to be able to do exactly what you want.

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

+1
source

It is very similar to what I'm working on right now, except that in my case I have to force the DNS server to return different error messages than usual in order to place it on a private network.

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

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

0
source

All Articles