method query give false back

Support forum for the PHP DNS Query API
Post Reply
pagyei
Posts: 3
Joined: Sun Feb 02, 2014 1:22 am

method query give false back

Post by pagyei » Sun Feb 02, 2014 2:31 am

Hello,

I tried to use your class,
By the first use it seems to work correctly but by trying featching DNSKEY-RR give the mothod false back.

Hope to get an answer soon

Saludos
Felipe

dave
Site Admin
Posts: 260
Joined: Fri May 30, 2008 9:09 pm
Location: UK
Contact:

Re: method query give false back

Post by dave » Mon Feb 03, 2014 7:14 pm

Hi,

Sorry to hear you are having a problem with PHPDNS.

First off DNSKEY-RR is not a type in PHPDNS. I think you mean DNSKEY or perhaps RRSIG? For a full list have a look at the source code: http://www.purplepixie.org/phpdns/viewf ... nc&ext=php.

Also can you provide some more details of your error ideally:

- What version of PHPDNS are you running?
- What is the exact query (type, question, server) you are using?

DNS RR through key seems to be working ok. However of course many domains don't have a DNSKEY set and will return blank (though this shouldn't be a direct false; this indicates some error).

- With the debug flag set what output do you get for your query?

If you could answer the three questions above I hope we can find your problem and fix it.

Regards,

Dave.

pagyei
Posts: 3
Joined: Sun Feb 02, 2014 1:22 am

Re: method query give false back

Post by pagyei » Mon Feb 03, 2014 10:29 pm

Yes I mean the DNS RR DNSKEY.
I have two domains with two KSK's and two ZSK's so 4 DNSKEY Records in a Domain.
I downloaded version 1.01 and started a test with 'A' and 'MX'.
Work perfectly but if I canche to DNSKEY I get bool 'false' from the method Query().
The method lasterror() tell me: 'Response too big for UDP, retry with TCP'.
OK this can I anderstand but how can I ask with TCP?

Code: Select all

<?php
require("dns.inc.php");
$dns = new DNSQuery('176.9.117.172');
$result = $dns->Query('xxxxx.net','DNSKEY');
echo var_dump($result);
echo $dns->lasterror;
?>
Saludos

dave
Site Admin
Posts: 260
Joined: Fri May 30, 2008 9:09 pm
Location: UK
Contact:

Re: method query give false back

Post by dave » Wed Feb 05, 2014 12:58 am

Hi,

To use TCP you need to set UDP as false in the constructor e.g.

Code: Select all

<?php
require("dns.inc.php");

$server="my.dns.server";
$port=53;  // TCP/UDP port for DNS (53 is the standard and default)
$timeout=60; // Timeout - default is 60s
$udp=false; // UDP as false, will use TCP

$query = new DNSQuery($server, $port, $timeout, $udp);

$type="DNSKEY";
$question="somedomain.org";

$result=$query->Query($question, $type);
?>
This will then use TCP as UDP is set to false.

Note: It is currently possible to directly set the UDP flag within the DNSQuery object e.g.

Code: Select all

$query->udp=false;
But a word of warning; this is an undocumented feature and so liable (albeit unlikely) to be removed in future versions. Using the constructor is the best method and code using this method will continue to work in future versions.

Hope that helps,

Dave.

pagyei
Posts: 3
Joined: Sun Feb 02, 2014 1:22 am

Re: method query give false back

Post by pagyei » Wed Feb 05, 2014 11:32 am

Yes it works now, I get the Keys but in the array I can't see the flag and the algorithm in the array.

Code: Select all

object(DNSAnswer)#3 (2) {
  ["count"]=>
  int(4)
  ["results"]=>
  array(4) {
    [0]=>
    object(DNSResult)#4 (9) {
      ["type"]=>
      int(48)
      ["typeid"]=>
      string(6) "DNSKEY"
      ["class"]=>
      int(1)
      ["ttl"]=>
      int(3600)
      ["data"]=>
      string(688) "AwEAAaAz3ixEvDFxKT7GzCl2nafqAEKXuU9OJfH+j6vShbfo5fkugeE6oANo4DtLqsma1Kmbp1TpxMq9P6wlVCYyDhvvtbaEzqWfT47QHftn/cXUmnqTRmwup1g/MtTganA813cJm11DNBoDwnpTSMiSlRMCoOKf3Gr0OfVBI1k/7ID9uQsGUnBcCghR9kbxQS3UN+sWPW0sZDNUUnJObl0RXnyYevmBfKBPj62ZPG6fEhb7qGt2o92sL+Wpzh586TuaK8HcJgvHhUbqT+IMhiRNo1Gbjh2dynjQ3tVEIGYqOGFJ5ZASbCWlhzktiHWRWfnP+T4eI1uKNQecHtqeBhPkxBf161N0guZV2vs+y4KktqYTBBnBiAl3bnRgu5f4S2k1IIXtakrGMAukeUvon9dMiK4GlNvIMOglJrSHh1PHmXIc0jzG3x1J/X43vmFXADR35JEEwY3Cj/3pJvVZJyKRrVoXpTlDuKIozAD4Y9VAK3rtNzSfT4lAHHvXHpKZnGn9cqcC/qiOLi7A6g+bcIX7+oUKRIU6kgnNmEmWdT9PO1zsqVkyUStpt9eHOCzDrLKONAUWN9Hr5YFR5swJ5Qeql8GRKpEpM5BH5PLueb106MV4UUGQAHgpmzFYyMP3/v7OU2BTkxQk5zXHO/fIFiGYyu310HAY6j96EUMbFAU5skb5"
      ["domain"]=>
      string(9) "domain.net"
      ["string"]=>
      string(702) "domain.net KEY AwEAAaAz3ixEvDFxKT7GzCl2nafqAEKXuU9OJfH+j6vShbfo5fkugeE6oANo4DtLqsma1Kmbp1TpxMq9P6wlVCYyDhvvtbaEzqWfT47QHftn/cXUmnqTRmwup1g/MtTganA813cJm11DNBoDwnpTSMiSlRMCoOKf3Gr0OfVBI1k/7ID9uQsGUnBcCghR9kbxQS3UN+sWPW0sZDNUUnJObl0RXnyYevmBfKBPj62ZPG6fEhb7qGt2o92sL+Wpzh586TuaK8HcJgvHhUbqT+IMhiRNo1Gbjh2dynjQ3tVEIGYqOGFJ5ZASbCWlhzktiHWRWfnP+T4eI1uKNQecHtqeBhPkxBf161N0guZV2vs+y4KktqYTBBnBiAl3bnRgu5f4S2k1IIXtakrGMAukeUvon9dMiK4GlNvIMOglJrSHh1PHmXIc0jzG3x1J/X43vmFXADR35JEEwY3Cj/3pJvVZJyKRrVoXpTlDuKIozAD4Y9VAK3rtNzSfT4lAHHvXHpKZnGn9cqcC/qiOLi7A6g+bcIX7+oUKRIU6kgnNmEmWdT9PO1zsqVkyUStpt9eHOCzDrLKONAUWN9Hr5YFR5swJ5Qeql8GRKpEpM5BH5PLueb106MV4UUGQAHgpmzFYyMP3/v7OU2BTkxQk5zXHO/fIFiGYyu310HAY6j96EUMbFAU5skb5"
      ["extas"]=>
      array(0) {
      }
      ["extras"]=>
      array(0) {
      }
    }
Normaly see the dns RR like:

Code: Select all

domain.net. 86400 IN DNSKEY 257 3 8 AwEAA....
256 or 257 says if it is KSK or ZSK and 8 the algorithm (8 is RSASHA256).

I need this for my class, maybe it's possible to add this in the result array?

Saludos Felipe

dave
Site Admin
Posts: 260
Joined: Fri May 30, 2008 9:09 pm
Location: UK
Contact:

Re: method query give false back

Post by dave » Sat Feb 22, 2014 12:29 am

Hi,

Sorry for the delay - I've implemented it and it seems to work ok on the latest development version. If you could test it that would be great, if it works ok I'll push up a general release.

The dev version is on github: https://github.com/purplepixie/phpdns where you can either clone the repo or just download the new dns.inc.php file.

In the extras field you will now get a keytype entry e.g.:

Code: Select all

DNSAnswer Object
(
    [count] => 2
    [results] => Array
        (
            [0] => DNSResult Object
                (
                    [type] => 48
                    [typeid] => DNSKEY
                    [class] => 1
                    [ttl] => 6429
                    [data] => BEAAAAOhHQDBrhQbtphgq2wQUpEQ5t4DtUHxoMVFu2hWLDMvoOMRXjGrhhCeFvAZih7yJHf8ZGfW6hd38hXG/xylYCO6Krpbdojwx8YMXLA5/kA+u50WIL8ZR1R6KTbsYVMf/Qx5RiNbPClw+vT+U8eXEJmO20jIS1ULgqy347cBB1zMnnz/4LJpA0da9CbKj3A254T515sNIMcwsB8/2+2E63/zZrQzBkj0BrN/9Bexjpiks3jRhZatEsXn3dTy47R09Uix5WcJt+xzqZ7+ysyLKOOedS39Z7SDmsn2eA0FKtQpwA6LXeG2w+jxmw3oA8lVUgEf/rzeC/bByBNsO70aEFTd
                    [domain] => isc.org
                    [string] => isc.org KEY BEAAAAOhHQDBrhQbtphgq2wQUpEQ5t4DtUHxoMVFu2hWLDMvoOMRXjGrhhCeFvAZih7yJHf8ZGfW6hd38hXG/xylYCO6Krpbdojwx8YMXLA5/kA+u50WIL8ZR1R6KTbsYVMf/Qx5RiNbPClw+vT+U8eXEJmO20jIS1ULgqy347cBB1zMnnz/4LJpA0da9CbKj3A254T515sNIMcwsB8/2+2E63/zZrQzBkj0BrN/9Bexjpiks3jRhZatEsXn3dTy47R09Uix5WcJt+xzqZ7+ysyLKOOedS39Z7SDmsn2eA0FKtQpwA6LXeG2w+jxmw3oA8lVUgEf/rzeC/bByBNsO70aEFTd
                    [extas] => Array
                        (
                        )

                    [extras] => Array
                        (
                            [keytype] => 257
                        )

                )

            [1] => DNSResult Object
                (
                    [type] => 48
                    [typeid] => DNSKEY
                    [class] => 1
                    [ttl] => 6429
                    [data] => BQEAAAABwuHz9Cem0BJ0JQTO7C/a3McR6hMaufljs1dfG/inaJpYv7vHXTrAOm/MeKp+/x6eT4QLru0KoZkvZJnqTI8JyaFTw2OM/ItBfh/hL2lmCft2O7n3MfeqYtvjPnY7dWghYW4sVfH7VVEGm958o9nfi79532Qeklxhx8pXWdeAaRU=
                    [domain] => isc.org
                    [string] => isc.org KEY BQEAAAABwuHz9Cem0BJ0JQTO7C/a3McR6hMaufljs1dfG/inaJpYv7vHXTrAOm/MeKp+/x6eT4QLru0KoZkvZJnqTI8JyaFTw2OM/ItBfh/hL2lmCft2O7n3MfeqYtvjPnY7dWghYW4sVfH7VVEGm958o9nfi79532Qeklxhx8pXWdeAaRU=
                    [extas] => Array
                        (
                        )

                    [extras] => Array
                        (
                            [keytype] => 256
                        )

                )

        )

)
Please let me know if that works ok for you.

Regards,

Dave.

dave
Site Admin
Posts: 260
Joined: Fri May 30, 2008 9:09 pm
Location: UK
Contact:

Re: method query give false back

Post by dave » Sat Feb 22, 2014 12:54 am

Hi,

Another update! Ok so there are three sets of figures given. The RFC shows them as flags, protocol and algorithm (without going into detail): http://www.ietf.org/rfc/rfc4034.txt

So all three of these values are now recovered in the extras section:

Code: Select all

DNSAnswer Object
(
    [count] => 1
    [results] => Array
        (
            [0] => DNSResult Object
                (
                    [type] => 48
                    [typeid] => DNSKEY
                    [class] => 1
                    [ttl] => 3570
                    [data] => AwEAAbukWBiANlK9hFC5sSr0GzUZs8vgWjL9pWwXEOjNghJk5Jwp3HEeWE8FX/bivpqIBaKBGFqZkCxIR1KnqO4NqH81U+zsg+yPTlF7orCC7FI0PbZpvpOsClH7DTepPJCphLwZcS2QWtENPNgP9CzRggoQW1lyjqsJzys9b+U6+dgr
                    [domain] => nominet.org.uk
                    [string] => nominet.org.uk KEY AwEAAbukWBiANlK9hFC5sSr0GzUZs8vgWjL9pWwXEOjNghJk5Jwp3HEeWE8FX/bivpqIBaKBGFqZkCxIR1KnqO4NqH81U+zsg+yPTlF7orCC7FI0PbZpvpOsClH7DTepPJCphLwZcS2QWtENPNgP9CzRggoQW1lyjqsJzys9b+U6+dgr
                    [extras] => Array
                        (
                            [flags] => 256
                            [protocol] => 3
                            [algorithm] => 5
                        )

                )

        )

)
Which shows the same data as dig:

Code: Select all

$ dig -t dnskey nominet.org.uk

; <<>> DiG 9.8.3-P1 <<>> -t dnskey nominet.org.uk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12961
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;nominet.org.uk.			IN	DNSKEY

;; ANSWER SECTION:
nominet.org.uk.		3459	IN	DNSKEY	256 3 5 AwEAAbukWBiANlK9hFC5sSr0GzUZs8vgWjL9pWwXEOjNghJk5Jwp3HEe WE8FX/bivpqIBaKBGFqZkCxIR1KnqO4NqH81U+zsg+yPTlF7orCC7FI0 PbZpvpOsClH7DTepPJCphLwZcS2QWtENPNgP9CzRggoQW1lyjqsJzys9 b+U6+dgr

;; Query time: 8 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Fri Feb 21 23:53:57 2014
;; MSG SIZE  rcvd: 180
Again it's now in the github repo as the dev version.

Let me know how you get on.

Regards,

Dave.

Post Reply