[Pdns-users] how to send NXDOMAIN from gmysql from a stored procedure?

aldus jung aldusj99 at gmail.com
Mon Jun 22 21:29:55 UTC 2015


Hi, I think my question is similar to the currently on-going discussion but
for the gmysql backend: [Pdns-users] How to send NXDOMAIN using pipe
backend?

I want to be able to return NXDOMAIN for queries where there are no
answers, and I don't know how to do this from a stored procedure.


The pdns-3.4.4 servers (running on RHEL 5.8) are configured to be
authoritative for 'dynamic.example.com', and its only job is returning A
records for that single sub-domain.
For example:
$>  'dig +short abc1.dynamic.example.com' would return:
128.59.152.21
128.159.15.22
128.29.15.23


I am using gmysql backend that calls a stored procedure for
'gmysql-any-id-query'

So if you were to query abc1.dynamic.example.com, you would see the
following queries:

 Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM
records WHERE disabled=0 and type='SOA' and name='abc1.dynamic.example.com'
 Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM
records WHERE disabled=0 and type='SOA' and name='dynamic.example.com'
 Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM
records WHERE disabled=0 and type='NS' and name='dynamic.example.com' and
domain_id=1
 Query: call dyn_query('abc1.dynamic.example.com', 1);

_________
The stored procedure looks like:
create procedure dyn_query(in_name VARCHAR(255), in_domain_id INT)
begin
     DECLARE case_condition INT;
      --- some processing to set the appropriate value for case_condition

     CASE
             WHEN (case_condition = 1) THEN
                  SELECT content,ttl,prio,type,domain_id,disabled,name,auth
FROM records WHERE disabled=0 and domain_id = 1 and name = 'in_name';

             WHEN (case_condition = 2) THEN
                  SELECT content,ttl,prio,type,domain_id,disabled,name,auth
FROM records WHERE disabled=0 and domain_id = 1 and name = 'in_name' and
.....;

              ELSE
                   BEGIN
                   END;
       END CASE;
end
_________

This works well when the "some processing" sets 'case_condition' to 1 or
2.  If it's anything else, I just want to return NXDOMAIN.  What's
happening is the following, and 'dig' just hangs for 6 seconds:

$> dig  dontexist.dynamic.example.com @pdnsserver344

; <<>> DiG 9.3.6-P1-RedHat-9.3.6-20.P1.el5_8.2 <<>>
dontexist.dynamic.example.com @pdnsserver344
;; global options:  printcmd
;; connection timed out; no servers could be reached


There isn't much in the pdns server's /var/log/messages either.  The query
looks exactly the same:

 Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM
records WHERE disabled=0 and type='SOA' and name='
dontexist.dynamic.example.com'
 Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM
records WHERE disabled=0 and type='SOA' and name='dynamic.example.com'
 Query: SELECT content,ttl,prio,type,domain_id,disabled,name,auth FROM
records WHERE disabled=0 and type='NS' and name='
dontexist.dynamic.example.com' and domain_id=1
 Query: call dyn_query('dontexist.dynamic.example.com', 1);


So is there something else that needs to be in ELSE clause for the CASE
statement..?  Thanks in advance for the help, and please let me know if I
left out any details.

aldusj
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.powerdns.com/pipermail/pdns-users/attachments/20150622/155d878f/attachment.html>


More information about the Pdns-users mailing list