Reputation: 3326
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.
Upvotes: 7
Views: 10815
Reputation: 551
"Ping " always performs a DNS lookup (both forward and reverse) before pinging the hostname in question. Writing a shell script to use ping (or dig) to see if ping is acting wonky is left as an exercise to the reader.
Another option is to use a caching DNS server on the local machine that caches replies from the upstream DNS server, and sends data from the cache when upstream is down. My own Deadwood is a tiny 32k Windows or UNIX binary that can do this (64k if you want full DNS recursion)
Upvotes: 0
Reputation: 5295
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');
Upvotes: 3
Reputation: 1321
but there is a little limitation of that function is Changelog: v. PHP 5.3.0 - This function is now available on Windows platforms.
if you dont want to update php on IIS. there is another alternative that executing dig for windows binary. here is dig for windows. you may also need that for your own not for any program. it's beyond of old-not-enough nslookup command.
Upvotes: 0
Reputation: 1238
http://www.php.net/manual/en/function.dns-get-record.php is the function in php it sounds like you are after.
Upvotes: 9