Skip to content

Native PHP DNS Client Resolver. Request DNS Record via UDP/TCP (RFC1035)

License

Notifications You must be signed in to change notification settings

ArrayAccess/DNS-Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP DNS Client - DNS Resolver

Native Php DNS Client / Resolver implementation of RFC 1035. Support PSR-6: Caching Interface.

Requirements

  • Php 8.1 or later
  • Function focksopen enabled & allowed outbound connection to port 53
  • Network Connectivity (Absolutely!)

Installing

Currently, in development:

composer require arrayaccess/dns-client

Usage

use ArrayAccess\DnsRecord\Cache\Adapter\Psr6CacheAdapter;
use ArrayAccess\DnsRecord\DnsServerStorage;
use ArrayAccess\DnsRecord\Resolver;

$cache = new Psr6CacheAdapter();
// $cache->setCacheItemPool($cacheProvider);
$dnsServer = DnsServerStorage::createDefault();
$resolver = new Resolver($dnsServer, $cache);

/**
 * Lookup Single 
 */
$useCache = true; // default to true
$timeout = 3.5; // 3.5 seconds
$response = $resolver->lookup('domain-name.ext', 'A', 'IN', $timeout, $useCache);

/**
 * Enable Pseudo OPT 
 */
$resolver->setDnsSec(true);
$response = $resolver->lookup('domain-name.ext', 'A', 'IN');
$answers = $response->getAnswers();
$records = $answers->getRecords();
// Filter "A" Address Only
$arrayA = $records->getFilteredType('A');

IXFR & AXFR aren't fully implemented yet

Note

The RRTypes not completed yet, will use RRDefault as default.