tags:

views:

276

answers:

5

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

A: 

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.

Michael Dillon
I do not think it is a good idea. BIND 9 (unlike what is planned for its successor BIND 10) is not really made for hackability.
bortzmeyer
That just means that it is not as easy to hack at BIND 9 because the source code is not as well organized and refactored. But sometimes developers just have to dig in and figure things out. In any case, the OP specified C and may be very skilled in its use, otherwise I would have suggested using Python and Twisted Names which comes with a DNS server for hacking.
Michael Dillon
+2  A: 

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/

eyalm
+1  A: 

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/

Alnitak
+1  A: 

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.

Bob.T.Terminal
A: 

In trying to get DLZ Bind to work with PostgreSQL, I made partial progress, but unfortunately the documentation for DLZ is somewhat lacking -- the authors did a good job with the documentation that is there, but what is missing is more detail on how the database needs to be set up, and some example zones. Without these example zones, it's a guessing game to get it working.

So, because DLZ Bind isn't working as expected, I'm starting to look at the Stanford::DNSserver Perl module as a possible alternative. It sure would be nice if there were a few examples of working zone data for Bind DLZ's "dns_records" table.

Randolf Richardson