Я нашел code с сайта msdn (приведенный ниже код), который выглядит так, как будто он вернет все псевдонимы dns для данного сервера. Я внедрил код в приложение со спасителем, которое должно позволить мне ввести имя хоста сервера и должно возвращать все имена псевдонимов DNS. Я ввожу имя хоста сервера в нашем домене, который, как известно, имеет псевдонимы (я могу пинговать хост и псевдонимы, и все они разрешают один и тот же IP-адрес), но этот код не находит псевдонимы. Obvously мое понимание Dns псевдонимов и/или код не хватает ... пожалуйста просветить меня ...запрос для dns-псевдонимов
static void Main(string[] args)
{
Console.Write("Host? (Enter for local): ");
string strHost = Console.ReadLine();
if (strHost.Trim().Length == 0)
{
strHost = System.Net.Dns.GetHostName();
}
try
{
//System.Net.IPAddress hostIPAddress = System.Net.IPAddress.Parse(strHost);
System.Net.IPHostEntry hostInfo = System.Net.Dns.GetHostByName(strHost);//.GetHostByAddress(hostIPAddress);
// Get the IP address list that resolves to the host names contained in
// the Alias property.
System.Net.IPAddress[] address = hostInfo.AddressList;
// Get the alias names of the addresses in the IP address list.
String[] alias = hostInfo.Aliases;
Console.WriteLine("Host name : " + hostInfo.HostName);
Console.WriteLine("\nAliases :");
for (int index = 0; index < alias.Length; index++)
{
Console.WriteLine(alias[index]);
}
Console.WriteLine("\nIP address list : ");
for (int index = 0; index < address.Length; index++)
{
Console.WriteLine(address[index]);
}
}
catch (System.Net.Sockets.SocketException e)
{
Console.WriteLine("SocketException caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
catch (FormatException e)
{
Console.WriteLine("FormatException caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
catch (Exception e)
{
Console.WriteLine("Exception caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
Console.WriteLine("Any key to continue...");
Console.ReadKey();
}