How to Build a custom simple DNS server in C/C++

c, c++, dns

Solution

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.

Problem

I need to build a custom simple non-authoritative caching DNS server in C/C++. Any guidance? Links? Samples?

Original source

Related problems