views:

261

answers:

2

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.

I see lots of examples of doing this with third party components in ASP but I would prefer to be able to do this with a single ASP / ASP.Net script that would be portable and not require anything additional be installed.

A: 

You can always Process.Start("nslookup") and parse the output.

Ben Scheirman
You should consider command line utilities only as the last option. Something as straight-forward as DNS lookups "should" be supported in the language library.
Martin v. Löwis
+4  A: 

You could simply do:

if (Dns.GetHostAddresses(hostName).Length == 0)
{
    // Host could not be resolved
}
Philippe Leybaert