Friday, August 19, 2011

Custom PowerDNS Backend

So here I go, I was busy to develop PowerDNS custom pipe backend, why I develop this because it need:

Filtering: If you familiar with internet filtering service such as OpenDNS or a local service Nawala, they can block domain names based on defined criteria. With custom backend all DNS client's queries are send to the backend, give the backend flexable way to manage them. Filtering or blocking was done by bypassing DNS A (IPv4) or AAAA (IPv6) plus additional SOA record to the client.

Logging: All DNS queries need to be logged for statistics, to generate complex statistics data, log storage should be in structural format such as database.

So I called this backend with cpdns, stand for Custom PowerDNS Backend, cpdns need these following programs.

  • Redis: advanced memory database server, its has key-value concept to store data, perfect for distributed object caching.

  • TCMalloc: fast and efficient memory allocator used by Redis.

  • libunwind: C API used by TCMalloc.

  • hiredis: Redis C client.

  • libldns: C DNS library used by backend's resolver.

  • MySQL: Famous RDBMS database to store domain filtering data and logs.

Short description about how the backend works, I'll divide backend's components based on their responsibility.

Query Parsing: PowerDNS