I have a Windows server that is intermittently losing the ability to lookup DNS information. I'm trying to get to the root cause of the problem but in the mean time I'd like to be able to monitor whether the server can perform lookups.
Basically, it should attempt to lookup some common hostnames and the display 'Success' if the lookups are successful.
The site runs PHP so I'd prefer that the monitor script be in PHP but if someone knows how to do this in ASP / .Net that would work as well.
http://www.php.net/manual/en/function.dns-get-record.php is the function in php it sounds like you are after.
On windows PHP DNS functions are not available natively prior to PHP 5.3. You will need the Pear Net_DNS Class. http://pear.php.net/package/Net_DNS
Example usage:
require_once 'Net/DNS.php';
$resolver = new Net_DNS_Resolver();
$resolver->debug = $this->debug;
// nameservers to query
$resolver->nameservers = array('192.168.0.1');
$resp = $resolver->query($domain, 'A');
source: http://code.google.com/p/php-smtp-email-validation/source/browse/trunk/smtp_validateEmail.class.php#232
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With