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.
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.
Upvotes: 1
Views: 1951
Reputation: 171734
You could simply do:
if (Dns.GetHostAddresses(hostName).Length == 0)
{
// Host could not be resolved
}
Upvotes: 5
Reputation: 40951
You can always Process.Start("nslookup") and parse the output.
Upvotes: -2