{"id":15022651,"url":"https://github.com/bluelibraries/php5-dns","last_synced_at":"2026-03-14T20:14:25.467Z","repository":{"id":151319220,"uuid":"622237301","full_name":"bluelibraries/php5-dns","owner":"bluelibraries","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-05T18:27:32.000Z","size":119,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-20T10:46:49.540Z","etag":null,"topics":["aaaa","dns","mx","php","php5","rrsig","soa","txt"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bluelibraries.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-01T14:24:43.000Z","updated_at":"2024-12-19T18:54:49.000Z","dependencies_parsed_at":"2023-06-27T00:43:28.918Z","dependency_job_id":null,"html_url":"https://github.com/bluelibraries/php5-dns","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluelibraries%2Fphp5-dns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluelibraries%2Fphp5-dns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluelibraries%2Fphp5-dns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluelibraries%2Fphp5-dns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bluelibraries","download_url":"https://codeload.github.com/bluelibraries/php5-dns/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243318758,"owners_count":20272144,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aaaa","dns","mx","php","php5","rrsig","soa","txt"],"created_at":"2024-09-24T19:58:14.242Z","updated_at":"2025-12-25T20:50:00.030Z","avatar_url":"https://github.com/bluelibraries.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DNS\n\n[![PHP-5.5 ](https://github.com/bluelibraries/php5-dns/actions/workflows/build-5.5.yml/badge.svg)](https://github.com/bluelibraries/php5-dns/actions/workflows/build-5.5.yml) \n[![PHP-5.6 ](https://github.com/bluelibraries/php5-dns/actions/workflows/build-5.6.yml/badge.svg)](https://github.com/bluelibraries/php5-dns/actions/workflows/build-5.6.yml) \n[![PHP-7.1 ](https://github.com/bluelibraries/php5-dns/actions/workflows/build-7.1.yml/badge.svg)](https://github.com/bluelibraries/php5-dns/actions/workflows/build-7.1.yml)\n[![PHP-7.3 ](https://github.com/bluelibraries/php5-dns/actions/workflows/build-7.3.yml/badge.svg)](https://github.com/bluelibraries/php5-dns/actions/workflows/build-7.3.yml)\n\n## FOR PHP  \u003e= 5.5 AND \u003c 7.4 ONLY\n\n## **For newer PHP version** we strongly suggest **[bluelibraries/dns](https://github.com/bluelibraries/dns)**\n\n## Use certain DNS handler for DNS interrogation\n \n**[Demo](https://gethostinfo.com/records/)**\n\n### Example:\n```php\n$records = DNS::getRecords('bluelibraries.com', RecordTypes::ANY);\nprint_r($records);\n```\n```text\nArray\n(\n    [0] =\u003e BlueLibraries\\Dns\\Records\\Types\\NS Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 21600\n                    [class] =\u003e IN\n                    [type] =\u003e NS\n                    [target] =\u003e ns3.instradns.com\n                )\n        )\n    [1] =\u003e BlueLibraries\\Dns\\Records\\Types\\A Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 21600\n                    [class] =\u003e IN\n                    [type] =\u003e A\n                    [ip] =\u003e 198.50.252.64\n                )\n        )\n)\n```\n\n## Install via `composer`\n```text\ncomposer require bluelibraries/php5-dns\n```\n\n\n### This package contains **4** types which can be used for DNS interrogations\n\n1. **DnsGetRecord** based on `dns_get_record` PHP function\n2. **Dig** based on `dig` shell command (better than `dns_get_record` and\n   still secured)\n3. **UDP** based on `raw` DNS calls using `UDP/socket` - useful for short\n   answered queries as UDP answers might be limited to `512` bytes\n4. **TCP** based on `raw` DNS calls\n   using `TCP/socket` - \u003cfont style=\"color:#3399FF; font-size:16px;font-weight:bold\"\u003ethis the best\u003c/font\u003e and is set\n   as `default` handler\n\n### Dns handlers comparison\n\n| Feature                                                       | DNS_GET_RECORD | DIG     | UDP     | TCP     |\n|---------------------------------------------------------------|----------------|---------|---------|---------|\n| **Force timeout** limit                                       | NO             | **YES** | **YES** | **YES** |\n| Detect **more record types** \u003cbr/\u003ethat are defined in **PHP** | NO             | **YES** | **YES** | **YES** |\n| Use **custom nameserver**                                     | NO             | **YES** | **YES** | **YES** |\n| Handle **large responses**                                    | **YES**        | **YES** | NO      | **YES** |\n| No need for **extra modules/packages** for running            | **YES**        | NO      | **YES** | **YES** |\n\n### Dns handlers custom settings\n```php\n// Let's customize the DNS request handler - TCP\n$dnsHandler = (new TCP())\n    -\u003esetPort(53)\n    -\u003esetNameserver('8.8.8.8')\n    -\u003esetTimeout(3) // limit execution to 3 seconds\n    -\u003esetRetries(5); // allows 5 retries if response fails\n\n// Let's initialize the DNS records service\n$dnsRecordsService = new DnsRecords($dnsHandler);\n\n// let's get some TXT records from `bluelibraries.com`\n$records = $dnsRecordsService-\u003eget('bluelibraries.com', RecordTypes::TXT);\n\n// let's display them\nprint_r($records);\n```\n```text\nArray\n(\n    [0] =\u003e BlueLibraries\\Dns\\Records\\Types\\TXT Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3600\n                    [class] =\u003e IN\n                    [type] =\u003e TXT\n                    [txt] =\u003e google-site-verification=kWtestq0tP8Ae_WJhRwUcZoqpdEkvuXJk\n                )\n        )\n    [1] =\u003e BlueLibraries\\Dns\\Records\\Types\\TXT Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3600\n                    [class] =\u003e IN\n                    [type] =\u003e TXT\n                    [txt] =\u003e 55d34914-636b-4x-b349-fdb9f2c1eaca\n                )\n        )\n)\n```\n### Similar for UDP and DIG\n```php\n$dnsHandler = (new UDP())\n    -\u003esetPort(53)\n    -\u003esetNameserver('8.8.8.8')\n    -\u003esetTimeout(3) // limit execution to 3 seconds\n    -\u003esetRetries(5); // allows 5 retries if response fails\n\n$dnsHandler = (new DIG())\n    -\u003esetPort(53)\n    -\u003esetNameserver('8.8.8.8')\n    -\u003esetTimeout(3) // limit execution to 3 seconds\n    -\u003esetRetries(5); // allows 5 retries if response fails\n```\n\n### DnsGetRecord - this handler has a limited number of settings\n```php\n// DnsGetRecord allows only Timeout and Retries, but there is no control over timeout\n// so the timeout may be much longer than the limit we set!\n$dnsHandler = (new DnsGetRecord())\n    -\u003esetTimeout(3) // limit execution to 3 seconds\n    -\u003esetRetries(5); // allows 5 retries if response fails\n```\n## Retrieve records examples, and more...\n- [A](./docs/Records/a.md)\n- [NS](./docs/Records/ns.md)\n- [CNAME](./docs/Records/cname.md)\n- [SOA](./docs/Records/soa.md)\n- [PTR](./docs/Records/ptr.md)\n- [HINFO](./docs/Records/hinfo.md)\n- [MX](./docs/Records/mx.md)\n- [TXT](./docs/Records/txt.md)\n  - [SPF](./docs/Records/Txt/spf.md)\n  - [DKIM](./docs/Records/Txt/dkim.md)\n  - [DMARC](./docs/Records/Txt/dmarc.md)\n  - [MtaSts](./docs/Records/Txt/mta-sts.md)\n  - [TlsReporting](./docs/Records/Txt/tls-reporting.md)\n  - [DomainVerification](./docs/Records/Txt/domain-verification.md)\n- [AAAA](./docs/Records/aaaa.md)\n- [SRV](./docs/Records/srv.md)\n- [NAPTR](./docs/Records/naptr.md)\n- [DS](./docs/Records/DnsSec/ds.md)\n- [RRSIG](./docs/Records/DnsSec/rrsig.md)\n- [NSEC](./docs/Records/DnsSec/nsec.md)\n- [DNSKEY](./docs/Records/DnsSec/dnskey.md)\n- [NSEC3PARAM](./docs/Records/DnsSec/nsec3param.md)\n- [CDS](./docs/Records/DnsSec/cds.md)\n- [CDNSKEY](./docs/Records/DnsSec/cdnskey.md)\n- [HTTPS](./docs/Records/https.md)\n- [CAA](./docs/Records/caa.md)\n\n\n### Retrieve records using `dns_get_record`\n\n```php\n$records = DNS::getRecords('bluelibraries.com', RecordTypes::TXT, DnsHandlerTypes::DNS_GET_RECORD);\nprint_r($records);\n```\n\n```text\nArray\n(\n    [0] =\u003e BlueLibraries\\Dns\\Records\\Types\\Txt\\DomainVerification Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [class] =\u003e IN\n                    [ttl] =\u003e 0\n                    [type] =\u003e TXT\n                    [txt] =\u003e google-site-verification=test-636b-4a56-b349-test\n                )\n        )\n)\n```\n\n### Retrieve records using `dig`\n\n```php\n$records = DNS::getRecords('bluelibraries.com', RecordTypes::TXT, DnsHandlerTypes::DIG);\nprint_r($records);\n```\n\n```text\nArray\n(\n    [0] =\u003e BlueLibraries\\Dns\\Records\\Types\\Txt\\DomainVerification Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [class] =\u003e IN\n                    [ttl] =\u003e 0\n                    [type] =\u003e TXT\n                    [txt] =\u003e google-site-verification=test-636b-4a56-b349-test\n                )\n        )\n)\n```\n\n### Retrieve records using `UDP`\n\n```php\n$records = DNS::getRecords('bluelibraries.com', RecordTypes::TXT, DnsHandlerTypes::UDP);\nprint_r($records);\n```\n\n```text\nArray\n(\n    [0] =\u003e BlueLibraries\\Dns\\Records\\Types\\Txt\\DomainVerification Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [class] =\u003e IN\n                    [ttl] =\u003e 0\n                    [type] =\u003e TXT\n                    [txt] =\u003e google-site-verification=test-636b-4a56-b349-test\n                )\n        )\n)\n```\n\n### Retrieve records using `TCP`\n\n```php\n// TCP is the default DNS handler, so if you are using it then you can skip it\n$records = DNS::getRecords('bluelibraries.com', RecordTypes::TXT);\nprint_r($records);\n```\n\n```text\nArray\n(\n    [0] =\u003e BlueLibraries\\Dns\\Records\\Types\\Txt\\DomainVerification Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [class] =\u003e IN\n                    [ttl] =\u003e 0\n                    [type] =\u003e TXT\n                    [txt] =\u003e google-site-verification=test-636b-4a56-b349-test\n                )\n        )\n)\n```\n\n### Retrieve TXT records\n\n```php\n$records = DNS::getRecords('bluelibraries.com', RecordTypes::TXT);\nprint_r($records);\n```\n\n```text\nArray\n(\n    [0] =\u003e BlueLibraries\\Dns\\Records\\Types\\Txt\\DomainVerification Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3454\n                    [class] =\u003e IN\n                    [type] =\u003e TXT\n                    [txt] =\u003e google-site-verification=kW9t2V_S7WjOX57zq0tP8Ae_WJhRwUcZoqpdEkvuXJk\n                )\n        )\n    [1] =\u003e BlueLibraries\\Dns\\Records\\Types\\TXT Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3454\n                    [class] =\u003e IN\n                    [type] =\u003e TXT\n                    [txt] =\u003e 55d14914-636b-4a56-b349-fdb9f2c1eaca\n                )\n        )\n)\n```\n\n### Retrieve A (address) records\n\n```php\n$records = DNS::getRecords('bluelibraries.com', RecordTypes::A);\nprint_r($records);\n```\n```text\nArray\n(\n    [0] =\u003e BlueLibraries\\Dns\\Records\\Types\\A Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3600\n                    [class] =\u003e IN\n                    [type] =\u003e A\n                    [ip] =\u003e 67.225.146.248\n                )\n        )\n)\n```\n\n\n### Retrieve ALL records\n```php\n$records = DNS::getRecords('bluelibraries.com', RecordTypes::ALL, DnsHandlerTypes::DIG);\nprint_r($records);\n```\n```text\nArray\n(\n    [0] =\u003e BlueLibraries\\Dns\\Records\\Types\\NS Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3600\n                    [class] =\u003e IN\n                    [type] =\u003e NS\n                    [target] =\u003e ns2.teestbluelibraries.com\n                )\n        )\n    [1] =\u003e BlueLibraries\\Dns\\Records\\Types\\Txt\\DomainVerification Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3600\n                    [class] =\u003e IN\n                    [type] =\u003e TXT\n                    [txt] =\u003e google-site-verification=errre\n                )\n        )\n    [2] =\u003e BlueLibraries\\Dns\\Records\\Types\\NS Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3600\n                    [class] =\u003e IN\n                    [type] =\u003e NS\n                    [target] =\u003e tst3.bluelibraries.com\n                )\n        )\n    [3] =\u003e BlueLibraries\\Dns\\Records\\Types\\TXT Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3600\n                    [class] =\u003e IN\n                    [type] =\u003e TXT\n                    [txt] =\u003e 55d34914-636b-4tes-b349-fdb9f2c1eaca\n                )\n        )\n    [4] =\u003e BlueLibraries\\Dns\\Records\\Types\\A Object\n        (\n            [data:protected] =\u003e Array\n                (\n                    [host] =\u003e bluelibraries.com\n                    [ttl] =\u003e 3600\n                    [class] =\u003e IN\n                    [type] =\u003e A\n                    [ip] =\u003e 67.225.146.248\n                )\n        )\n)\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluelibraries%2Fphp5-dns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluelibraries%2Fphp5-dns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluelibraries%2Fphp5-dns/lists"}