Loading

PowerDNS recursor Lua scripting examples

Today, while on the train, i finally took some time to extract some Lua scripting examples to run in PowerDNS recursor from my code.

Creative Commons License

UPDATE: because someone asked if they could use my code for their presentations i hereby declare the code examples linked in this article licensed Creative Commons Attribution 3.0 Unported License

ANOTHER UPDATE: These examples assume that you are using the latest and greatest svn trunk version of PowerDNS recursor, for v 3.1.7.2 and below (you really should update) the scripts will work if you remove any occurence of the destination variable. Also please note that the Packet Cache for the recursor in svn trunk will collide with said destination variable, you will have to disable it to use the lower two scripts in their original form.

YET ONE MORE UPDATE: With the upcoming version 3.2 of PowerDNS recursor instead of

function preresolve ( ip, destination, domain, qtype )

you would need to write

function preresolve ( ip, domain, qtype ) destination=getlocaladdress()

Would you like to know more?

So here we go.

The first one is a simple override.

The second one is about query logging with some conditions.

And finally this should be a working example for NXDOMAIN Redirection aka the Sitefinder way. Yes i know, i know, one does simply not do such an ugly thing but i fear these days many ISPs actually do it. sigh

Just in case if you wanna mock about me using iframe ins this article, i simply was tired of integrating javascript code highlighting into it and turned to pygmentize: for file in ls *.lua; do rm $file.html; echo '" >> $file.html; pygmentize -l lua -f html -F highlight -O style=trac $file >> $file.html; done

grr

Bert Hubert finaly blogs (again)

Ok, so Bert Hubert wrote another article and i thought: “damn, now i need to think of something to post to my blog in order not to lag behind”.

Well guess what i found something to blog about. That very same post that you can also digg btw. ;-)

What he says is in essence that for large programming projects you go through a refinement process that you have probably never planned for but nonetheless will experience just as he has with PowerDNS and that you need a userbase that does error reports and sticks with the project in order to pull it of.

Wait, users? Oh yeah thats me too… Hmm so this post is about me, err no us. Hello community.

Btw. what he says about the PowerDNS recursor is very true, it is a remarkably mature product now.

Starting with version 3.1.4 i did not experience a single software induced crash of our 20 running recursor processes where with BIND9 it was a bi-weekly annoyance. Also the switch to PowerDNS recursor cut SERVFAIL responses to half of what they were before.

Update: I need to correct myself there, median SERVFAIL responses are roughly 1/10th of what i experienced with BIND9 longterm. That may of course denote that authoritative Server operators are more on the lookout for misconfigurations now than they were ~3 years ago, but i seriously doubt that.

Second Amendment: Ok the title was corrected, Its not Bert Huber, sorry ;)