find the hostname for a known IP address

November 24, 2008 by admin  
Filed under C Sharp

find the hostname for a known IP address with C Sharp

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

Related posts:

  1. perform a DNS query perform a DNS query on a domain name using 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. Display network information using Powershell  This example will display various snippets of network related information...
  5. Log users IP address This ASP example will retrieve a visitors IP address and...

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!