[Pdns-users] backend NAPTR no Answer - powerdns

Tyler Parkin tyler at foxfam.com
Sat Nov 15 20:56:08 UTC 2008


Well, finally got it.  I had assumed that pdns was going to parse the entire
output from the script (including the content), which isn't the case.  The
tabs in the output were screwing me up.  I removed the tabs in the content
and it pulls it in as a single string.  Also had to change the elsif
statements to regular if's so it would eval each one for ANY requests.

Working script is below:

#!/usr/bin/perl -w
# sample PowerDNS Coprocess backend
#
use strict;
$|=1; # no buffering
my $line=<>;
chomp($line);
unless($line eq "HELO\t1") {
print "FAIL\n";
print STDERR "Recevied $line\n";
<>;
exit;
}
print "OK Sample backend firing up\n"; # print our banner
while(<>)
{
print STDERR "$$ Received: $_";
chomp();
my @arr=split(/\t/);


if(@arr<6) {
print "LOG PowerDNS sent unparseable line\n";
print "FAIL\n";
next;
}
my ($type,$qname,$qclass,$qtype,$id,$ip)=split(/\t/);
if(($qtype eq "SOA") && $qname eq "privatelnp.foxfam.net") {
        print
"DATA\t$qname\t$qclass\tSOA\t3600\t-1\tdns.privatelnp.foxfam.net.
help.privatelnp.foxfam.net. 1 10800 3600 604800 3600\n";
        print STDERR
"DATA\t$qname\t$qclass\tSOA\t3600\t-1\tdns.privatelnp.foxfam.net.
help.privatelnp.foxfam.net. 1 10800 3600 604800 3600\n";
}
if(($qtype eq "A" || $qtype eq "ANY") && $qname eq "privatelnp.foxfam.net")
{
        print "DATA\t$qname\t$qclass\tA\t3600\t-1\t66.49.125.190\n";
        print STDERR "DATA\t$qname\t$qclass\tA\t3600\t-1\t66.49.125.190\n";
}
if(($qtype eq "CNAME" || $qtype eq "ANY") && $qname eq
"dns.privatelnp.foxfam.net") {
        print
"DATA\t$qname\t$qclass\tCNAME\t3600\t-1\tprivatelnp.foxfam.net\n";
        print STDERR
"DATA\t$qname\t$qclass\tCNAME\t3600\t-1\tprivatelnp.foxfam.net\n";
}
if(($qtype eq "NS" || $qtype eq "ANY") && $qname =~ /privatelnp.foxfam.net/)
{
        print
"DATA\t$qname\t$qclass\tNS\t3600\t-1\tdns.privatelnp.foxfam.net\n";
        print STDERR
"DATA\t$qname\t$qclass\tNS\t3600\t-1\tdns.privatelnp.foxfam.net\n";
}
if(($qtype eq "NAPTR" || $qtype eq "ANY") && $qname =~
/privatelnp.foxfam.net/) {
my $naptrstring = "DATA\t$qname\t$qclass\tNAPTR\t3600\t-1\t100 50 \"U\"
\"E2U+sip\" \"!^.*\$!sip:tparkin\@foxfam.com!\" .\n";
        print $naptrstring;
        print STDERR $naptrstring;
}
print STDERR "$$ End of data\n";
print "END\n";
}

-----Original Message-----
From: pdns-users-bounces at mailman.powerdns.com
[mailto:pdns-users-bounces at mailman.powerdns.com] On Behalf Of Tyler Parkin
Sent: Friday, November 14, 2008 3:48 PM
To: pdns-users at mailman.powerdns.com
Subject: [Pdns-users] backend NAPTR no Answer - powerdns


Can someone help me identify what's wrong w/ the syntax of an NAPTR record? 
I've tried a dozen different arrangements and can't seem to get PDNS to send
an answer to the query.  It doesn't cought at the data line I feed, it just
doesn't sent anything.

Nov 14 12:40:51 Query: 'Q       5.5.5.1.2.1.2.privatelnp.foxfam.com      IN

ANY     -1      66.49.125.190'
10622 Received: Q       5.5.5.1.2.1.2.privatelnp.foxfam.com      IN      ANY

-1      66.49.125.190
DATA    5.5.5.1.2.1.2.privatelnp.foxfam.com      IN      3600    NAPTR   100

50      "U"     "E2U+sip"       "!^.*$!sip:tparkin at foxfam.com!"      .
10622 End of data

Nov 14 12:40:51 Query: 'Q       *.5.5.1.2.1.2.privatelnp.foxfam.com      IN

ANY     -1      66.49.125.190'
10622 Received: Q       *.5.5.1.2.1.2.privatelnp.foxfam.com      IN      ANY

-1      66.49.125.190
DATA    *.5.5.1.2.1.2.privatelnp.foxfam.com      IN      3600    NAPTR   100

50      "U"     "E2U+sip"       "!^.*$!sip:tparkin at foxfam.com!"      .
10622 End of data


I've tried w/ and w/out the period, 3600, IN and NAPTR and it won't send
anything through.

It DOES send SOA fine, so dig naptr requests show up as authoritative with
no answer.

pertinent part from the perl backend:

elsif(($qtype eq "NAPTR" || $qtype eq "ANY") && $qname =~
/privatelnp.foxfam.com/) {
my $naptrstring =
"DATA\t$qname\t$qclass\t3600\tNAPTR\t100\t50\t\"U\"\t\"E2U+sip\"\t\"!^.*\$!s
ip:tparkin\@foxfam.com!\"\t.\n";
        print $naptrstring;
        print STDERR $naptrstring;
}


dig request:
[root at breadbox ~]# dig NAPTR @66.49.125.190
5.5.5.1.2.1.2.privatelnp.foxfam.com NAPTR

;; Warning, extra type option

 

; <<>> DiG 9.3.4-P1 <<>> NAPTR @66.49.125.190 5.5.5.1.2.1.2.
privatelnp.foxfam.com NAPTR

; (1 server found)

;; global options:  printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 864

;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

 

;; QUESTION SECTION:

;5.5.5.1.2.1.2.privatelnp.foxfam.com. IN NAPTR

 

;; AUTHORITY SECTION:

privatelnp.foxfam.com.   3600    IN      SOA     dns.privatelnp.foxfam.com.
help. privatelnp.foxfam.com. 1 10800 3600 604800 3600

 

;; Query time: 3 msec

;; SERVER: 66.49.125.190#53(66.49.125.190)

;; WHEN: Fri Nov 14 12:56:51 2008

;; MSG SIZE  rcvd: 117



-- 
View this message in context:
http://www.nabble.com/backend-NAPTR-no-Answer---powerdns-tp20508024p20508024
.html
Sent from the PowerDNS mailing list archive at Nabble.com.

_______________________________________________
Pdns-users mailing list
Pdns-users at mailman.powerdns.com
http://mailman.powerdns.com/mailman/listinfo/pdns-users



More information about the Pdns-users mailing list