Net_DNS2 v1.4.4 – Bugfixes and Updates for PHP 7.2

I’ve released version 1.4.4 of the PEAR Net_DNS2 library- this release is primarily just bug fixes.

You can install it now through the command line PEAR installer:

pear install Net_DNS2

Or, you can also add it to your project using composer:

composer require pear/net_dns2

Version 1.4.4

  • Bugfix when returning an empty bitmap-type in BitMap.php – patch from BugMaster510945.
  • Added the BIND 9 private record RR (TYPE65534) – patch from BugMaster510945.
  • Added DNSSEC algorithms 13-16 (ECDSAP256SHA256, ECDSAP384SHA384, ED25519, and ED448).
  • Added SSHFP algoritm ED25519.
  • Modified Net_DNS2::sendPacket() to use current()/next() rather than the deprecated each() (deprecated in 7.2).

2 thoughts on “Net_DNS2 v1.4.4 – Bugfixes and Updates for PHP 7.2

  1. Todd Hammer


    I was looking for a native PHP solution (so I wouldn’t have to call exe()) to lookup our Domain Controller on the network. Your example works perfectly but when I try:
    $resolver-query(‘’, ‘SRV’);

    I get the following error: PHP Notice: Undefined property: Net_DNS2_RR_SRV::$address in – on line 11

    I don’t think I am using it wrong. So, I parsed the object and found an ‘additional’ section that lists the address. Can I count on ‘additional’ being present in every response?

    My code is:

    require ‘/opt/rh/rh-php70/root/usr/share/pear/Net/DNS2.php’;
    $r = new Net_DNS2_Resolver();

    $result = $r->query(‘’, ‘SRV’);

    foreach($result->answer as $record)
    echo $record->address, “\n”;

    } catch(Net_DNS2_Exception $e)
    echo “::query() failed: “, $e->getMessage(), “\n”;


  2. mike Post author

    Hey Todd,

    $address isn’t a property returned in the SRV object (Net_DNS2_RR_SRV) object itself; if you look at the RR/SRV.php class, you’ll see the properties returned in SRV (priority, weight, target, port, and target).

    The additional section is optionally populated by the DNS resolver. In the case of SRV, the next likely DNS lookup request will be for the A record for the $target host name(s) returned. The A record has an $address value, which is why you’re seeing it.

    But you can’t rely on this value being returned. What I would suggest, is that you:

    1) do the SRV lookup, and find the $target you’re looking for;
    2) check to see if the additional section was populated, and if there is a A record for the $target host name you’re looking for. If there is, you have your $address value;
    3) if $additional is empty, or doesn’t contain an entry for your $target, then do a new A lookup for the $target and get the $address.

    Let me know if that makes sense,


Leave a Reply

Your email address will not be published. Required fields are marked *