jfarrell
jfarrell

Reputation: 4600

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. 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

Upvotes: 3

Views: 6310

Answers (4)

jfarrell
jfarrell

Reputation: 4600

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.

Upvotes: 1

Alnitak
Alnitak

Reputation: 340055

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/

Upvotes: 1

eyalm
eyalm

Reputation: 3366

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/

Upvotes: 2

Michael Dillon
Michael Dillon

Reputation: 32392

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.

Upvotes: 1

Related Questions