Net_DNS: DNS Resolver for PHP

Net_DNS: A resolver library written in native PHP

PLEASE NOTE: This code has been incorporated into PEAR. This page is here for historical/reference purposes only. Please use the PEAR packages for Net_DNS. The downloads here are not considered stable and the documentation and examples I wrote for PEAR are much more complete and consistent.

Net_DNS is a resolver library written in PHP. It was ported to PHP from the PERL Net::DNS module. Very little of the code contained in this class is my own. Most of it is a direct port from the PERL module.
  • 5-15-2002: Version 0.01 released (devel)
      Initial release. Fairly unusable.
  • 8-15-2002: Version 0.02 released (beta)
      Many bugs fixed. TSIG RR type added for dynamic DNS updates.
  • 9-15-2002: Version 0.03 released (beta)
      Now has stable support of DNS queries, socket handling, and packet parsing/generating. Any problems at this point should be considered bugs and should be reported ASAP. Running this code with E_ALL should be acceptable -- any warnings generated should be submitted to

In fact, the only thing that is really my code is the UDP data transmission code, simply because socket support in PHP is still considered "EXPERIMENTAL." This will be rectified when socket support is finalized.

First of all, let me start by saying that I am _NOT_ a PERL programmer. Since taking on this project, I have learned an entirely new hatred of PERL. Not only is it slow and cumbersome, it also has a lot of incredibly retarted "features" and a ridiculous syntax. Although i can read PERL quite well, I can not write it. If you find any oddities, this is probably the reason. Please let me know of ANY problems you find.

This class is by no means complete. As of this writing, the distribution only contains support for A, NS, and CNAME RR types. Feel free to add support for other types and send them to me. I will be adding more support for various RR types when *I* need them, or when someone requests it. If you need a specific RR type done, please let me know at


Documentation for Net_DNS can be found on the PEAR website at

You can find documentation for the PERL Net::DNS module at As one would expect, there are some differences between the PERL version and my version. Some of these limitations are caused by language semantics, others because I didn't like the original design.

Bugs and Limitations

This release should be relatively bug free. If you find a bug, please let me know.


Copy the packaged files from the archive into your PHP include directory. If you have the PEAR modules installed, you can copy the files under the Net directory.

I have finished getting everything PEAR compliant and Net_DNS is now part of PEAR. If you have pear installed, you can simply type:

    # pear install Net_DNS

Otherwise, you will need to install manually. The PHP include directory is usually /usr/share/php or /usr/local/lib/php. This directory can be determined by examining your php.ini file. If your include directory is /usr/share/php, and you have PEAR installed, issue:

    # cp -Rp Net_DNS-0.03beta-CVS/* /usr/share/php/Net/