NetDNS2 – PHP DNS Resolver and Updater

The NetDNS2 library is a pure PHP DNS Resolver library, that supports local caching, dynamic DNS updates, and almost every feature currently supported by modern DNS servers.

The main features for this package include:

  • PSR-4 style autoloading, and namespace semantics (as of v2.0)
  • Support for IPv4 and IPv6, UDP, TCP, and TLS sockets.
  • Support for DNS over TLS (DoT).
  • Support for DNS over HTTP (DoH) using RFC 8484 application/dns-message format.
  • Support for all defined (and not obsoleted) resource record types.
  • Support for DNSSEC requests and resource records.
  • Support for EDNS(0) features (client subnet, cookies, TCP keepalive, etc.)
  • Support zone signing using TSIG and SIG(0) for updates and zone transfers.
  • Includes a separate Updater class for handling dynamic DNS updates.
  • Includes a separate Notifier class for sending DNS notification messages.
  • Includes a local cache using shared memory, flat file, Memcached, or Redis to improve performance.

Installing NetDNS2

Install using Composer:

composer require mikepultz/netdns2

Or grab a copy from GitHub: https://github.com/mikepultz/netdns2

Requirements

  • PHP 8.1+ – this version uses strong typing, ENUMs, and other modern PHP features, and will not work with older versions of PHP.
  • (OPTIONAL) OpenSSL – for DNS over TLS (DoT) and certain resource record types.
  • (OPTIONAL) cURL – for DNS over HTTP (DoH).
  • (OPTIONAL) Hash – for TSIG request authentication.
  • (OPTIONAL) Intl – for decoding Unicode domains.
  • (OPTIONAL) Sodium – for ED25519 algorithm support in DNSSEC signature verification.
  • (OPTIONAL) Shmop – for local caching
  • (OPTIONAL) Memcached – for local caching.
  • (OPTIONAL) Redis – for local caching.

Using NetDNS2

See https://github.com/mikepultz/netdns2?tab=readme-ov-file#using-netdns2 for more details.

Change Log

See the CHANGES file.