项目作者: gurkanbicer

项目描述 :
It collects DNS results using dig command.
高级语言: PHP
项目地址: git://github.com/gurkanbicer/advanced-dns.git
创建时间: 2019-08-14T13:03:19Z
项目社区:https://github.com/gurkanbicer/advanced-dns

开源协议:MIT License

下载


Advanced DNS

It collects DNS results using dig command.

Supported DNS Query Types

  • A
  • AAAA
  • CNAME
  • MX
  • NS
  • SOA
  • TXT

Installation

  1. composer require gurkanbicer/advanced-dns
  1. require 'vendor/autoload.php';
  2. use \Gurkanbicer\AdvancedDns\AdvancedDns;

Samples

Sample 1:

  1. $domain = new AdvancedDns('getdns.sh');
  2. $result = $domain->lookup('NS', '8.8.8.8');
  3. var_dump($result);

Output:

  1. array(4) {
  2. ["type"]=>
  3. string(2) "NS"
  4. ["status"]=>
  5. string(7) "NOERROR"
  6. ["nameserver"]=>
  7. string(7) "8.8.8.8"
  8. ["response"]=>
  9. array(2) {
  10. ["amit.ns.cloudflare.com"]=>
  11. array(2) {
  12. ["ttl"]=>
  13. int(21599)
  14. ["data"]=>
  15. array(1) {
  16. [0]=>
  17. string(13) "173.245.59.63"
  18. }
  19. }
  20. ["april.ns.cloudflare.com"]=>
  21. array(2) {
  22. ["ttl"]=>
  23. int(21599)
  24. ["data"]=>
  25. array(1) {
  26. [0]=>
  27. string(13) "173.245.58.66"
  28. }
  29. }
  30. }
  31. }

Sample 2:

  1. $domain = new AdvancedDns('getdns.sh');
  2. $result = $domain->authorityNameserverLookup();
  3. var_dump($result);

Output:

  1. array(4) {
  2. ["type"]=>
  3. string(8) "DOMAINNS"
  4. ["response"]=>
  5. array(2) {
  6. ["amit.ns.cloudflare.com"]=>
  7. array(2) {
  8. ["ttl"]=>
  9. int(86400)
  10. ["data"]=>
  11. array(1) {
  12. [0]=>
  13. string(13) "173.245.59.63"
  14. }
  15. }
  16. ["april.ns.cloudflare.com"]=>
  17. array(2) {
  18. ["ttl"]=>
  19. int(86400)
  20. ["data"]=>
  21. array(1) {
  22. [0]=>
  23. string(13) "173.245.58.66"
  24. }
  25. }
  26. }
  27. ["status"]=>
  28. string(7) "NOERROR"
  29. ["nameserver"]=>
  30. string(9) "a2.nic.sh"
  31. }

Error Handling

  1. // if there is no error
  2. if ($result !== false && $result['status'] == 'NOERROR') {
  3. var_dump($result);
  4. }

If there is no response that your queried host:

  1. array(4) {
  2. ["type"]=>
  3. string(4) "AAAA"
  4. ["status"]=>
  5. string(7) "NOERROR"
  6. ["nameserver"]=>
  7. string(7) "8.8.8.8"
  8. ["response"]=>
  9. array(0) {
  10. }
  11. }

If somethings goes bad or if has not in the list that your query type, output will be like:

  1. bool(false)