- Is mikepultz/netdns2 a Laravel package, or just a plain PHP library?
- It is a low-level, framework-agnostic PHP DNS protocol library with older PEAR-style Net_DNS2_* class names, not a Laravel package. It has no service provider, config file, facade, or Laravel conventions built in. You can install it with Composer inside a Laravel app, but you must write your own glue: a service provider, configuration, secret handling, and exception mapping. Treat it as an infrastructure dependency, not a domain layer component.
- How do I install mikepultz/netdns2 in a Laravel project?
- Run composer require mikepultz/netdns2 and pin the version in composer.json. There is no package auto-discovery, so nothing is registered automatically and no config is published. After installing, confirm that Composer autoloading works in your app and that required extensions such as sockets and openssl are available in your runtime. Then build a small service provider that binds your own resolver and updater interfaces.
- Which PHP and Laravel versions does Net_DNS2 support?
- The library is pure PHP and requires no external PHP extensions, but it does not officially publish a Laravel support matrix. Laravel 10, 11, and 12 compatibility needs to be verified in a short spike on the oldest and newest PHP versions you run in production. During that spike, watch for PHP deprecation warnings from the legacy class naming and confirm autoloading and extension requirements behave as expected.
- How do I query MX, TXT, SRV, or AAAA records with Net_DNS2?
- Create a Net_DNS2_Resolver instance, optionally passing custom name servers and timeout settings, then call query with a hostname and record type such as MX, TXT, SRV, AAAA, A, NS, or CNAME. The library returns structured answer objects you can map into your own DTOs so Net_DNS2 types do not leak into application code. It supports UDP and TCP plus IPv4 and IPv6 name servers, which covers most lookup use cases.
- Can mikepultz/netdns2 perform dynamic DNS updates with TSIG?
- Yes. Net_DNS2 supports RFC2136-style dynamic updates and TSIG signing, which is the main reason to pick it over native PHP lookup functions. TSIG keys authorize zone changes, so store them encrypted in environment or secret management and scope them to least privilege. Run updates only in queued jobs, on explicitly approved zones, with audit logging and a dry-run path.
- Does Net_DNS2 work with Cloudflare, Route 53, or Google Cloud DNS?
- No. It speaks the DNS protocol directly and does not implement provider REST APIs, so it is the wrong tool for Route 53, Cloudflare, Azure DNS, or Google Cloud DNS record management. It only makes sense for nameservers that accept RFC2136 dynamic updates with TSIG, and many managed providers do not support that. If you manage records through a provider, use that provider's SDK or API instead.
- How should I wrap Net_DNS2 in a Laravel service provider?
- Define your own DnsResolverService and DnsUpdaterService interfaces and bind implementations that call the Net_DNS2 classes internally. Add a config file for nameservers, timeouts, retries, cache TTL, and TSIG credentials, and map package exceptions to your own application-specific DNS exceptions. Controllers, jobs, models, and Blade views should never touch Net_DNS2_* classes directly. Write contract tests against the interfaces so you can swap the underlying library later.
- Is it safe to call Net_DNS2 in a request path, or does it block?
- All queries are synchronous and blocking, so using it directly in a controller can add latency or hang under DNS failures. Bound every call with a short timeout, cache results with a sensible TTL, and keep dynamic updates in queued jobs. Also test truncated UDP responses and TCP fallback, plus NXDOMAIN, SERVFAIL, and timeout behaviour against your actual nameservers.
- What SSRF or security risks come with a DNS resolver library in Laravel?
- If users can control the hostname or record type being looked up, they may be able to probe internal names or exfiltrate data through DNS queries. Constrain allowed hostnames and record types, restrict which nameservers may be used, and never let request input pick the resolver target freely. For updates, encrypt TSIG secrets, restrict them to specific zones, and log every change. Keep package exceptions from surfacing raw DNS details to end users.
- Is mikepultz/netdns2 actively maintained, and what are the alternatives?
- It is MIT licensed with a recent release, which is a positive signal, but roughly 142 stars and niche adoption suggest limited ecosystem momentum. Alternatives include native PHP functions like dns_get_record and checkdnsrr for simple lookups, provider SDKs for managed DNS, or other resolver libraries. Because the package has no Laravel conventions and carries vendor risk, pin the version and keep it behind your own interfaces so replacing it is a contained change.