perform a DNS query

November 23, 2008 by admin  
Filed under C Sharp

perform a DNS query on a domain name using C Sharp

using System;
using System.Net;
class GetDnsInfo
{
public static void Main(string[] argv)
{
if (argv.Length != 1)
{
Console.WriteLine("Usage: GetDnsInfo hostname");
return;
}
IPHostEntry results = Dns.GetHostByName(argv[0]);
Console.WriteLine("Host name: {0}",
results.HostName);
foreach(string alias in results.Aliases)
{
Console.WriteLine("Alias: {0}", alias);
}
foreach(IPAddress address in results.AddressList)
{
Console.WriteLine("Address: {0}",
address.ToString());
}
}
}

Related posts:

  1. find the hostname for a known IP address find the hostname for a known IP address with C...
  2. Displays your IP address and hostname This example will display your IP address and hostname using...
  3. get ip address get ip address with VB.net Module Module1 Sub Main() Dim...
  4. free disk space This example shows how to display the free disk space,...
  5. free disk space, wmi version free disk space, wmi version with C Sharp using System;using...

Related posts brought to you by Yet Another Related Posts Plugin.

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!