Native Php DNS Client / Resolver implementation of RFC 1035. Support PSR-6: Caching Interface.
Php 8.1
or later- Function
focksopen
enabled & allowed outbound connection to port53
- Network Connectivity (Absolutely!)
Currently, in development:
composer require arrayaccess/dns-client
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
The RRTypes not completed yet, will use RRDefault as default.