/pdnsapp

PowerDNS-based python DNS application microframework

Primary LanguagePythonGNU General Public License v2.0GPL-2.0

Deprecation notice

The project is deprecated now and this repo has been archived. I moved to CoreDNS which is not only waaay faster, but covers all features pdnsapp had. Ok.. well, almost all. I had to develop some extra coredns plugins to port some niche features anyone would have barely needed on the long run.


pdnsapp

This is a python microframework to help develop DNS-based applications, very much like bottle.py for HTML or lamsonproject for SMTP. It's 'application server' is PowerDNS.

Examples

1. example: myip

The following code will resond with the IP-address of the querying client for myip.end.re:

@match(fqdn='myip.end.re',type='A')
def myip(request):
    return A(data=request['remote-ip'])

2. example: catch-all

Be authoritative for all the zones. It's like wildcards on steroids. Or like PowerDNS superslave being a supermaster instead.

@match(type='SOA')
def catchall(request):
    return SOA("ns0.end.re dnsadm2.end.re %s 10800 3600 604800 3600" % strftime("%Y%m%d%H"))

@match(type='NS')
def catchall(request):
    return [
        NS('ns0.end.re'),
        NS('ns1.end.re'),
    ]   

3. example: geoip

Simple geoip implementation, this one returns differenct IP address for mx0.end.re depending on the client IP address.

from radix import Radix
rtree = Radix()

for subnet in ['192.168.0.0/24', '192.168.1.0/24']:
    rtree.add(subnet)

@match(type='A', fqdn='mx0.end.re')
def geoip(request):
    if rtree.search_best(request['remote-ip']): #if requesting client is in the prefixes listed
        return A('192.168.1.1')
    else:
        return A('44.128.1.1')

4. example: dynamic reverse records

This is for generating reverse (PTR) DNS entries and their forward (A/AAAA) lookup.