How to Build a custom simple DNS server in C/C++
I wrote a basic DNS server for a job interview under BSD license.
May be someone could find it useful:
https://github.com/tomasorti/dns-server
There's no such thing as a "simple" cacheing DNS server, particularly if you want decent security. Recent DNS attacks have shown that the cacheing function in recursive DNS servers is particularly vulnerable.
Re-evaluate whether you actually need local cacheing of your own. If you don't, you're probably better off modifying existing DNS proxy code (such as 'dnsmasq').
If you do want to roll-your-own, there are good libraries such as ldns
which can provide the access to the underlying DNS packets.
I'm using ldns
myself in conjunction with libevent
to implement the Fuzzing DNS server I mentioned in an earlier question.