反向IP域检查?

时间:2009-04-04 08:08:44

标签: c# dns

有一个网站,您可以使用域进行查询,它将返回该IP上托管的所有网站的列表。我记得在C#中有一个类似于ReturnAddresses或类似东西的方法。有谁知道这是怎么做的?查询主机名或IP并返回主机名列表,也就是托管在同一服务器上的其他网站?

网站是:http://www.yougetsignal.com/tools/web-sites-on-web-server/

3 个答案:

答案 0 :(得分:19)

阅读评论后,bobince肯定是对的,这两个应该相互配合使用。为获得最佳结果,您应在此处使用反向DNS查找以及使用被动DNS复制。

string IpAddressString = "208.5.42.49"; //eggheadcafe

try 
{
   IPAddress hostIPAddress = IPAddress.Parse(IpAddressString);
   IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
   // Get the IP address list that resolves to the host names contained in 
   // the Alias property.
   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(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);
}

http://www.eggheadcafe.com/community/aspnet/2/83624/system-dns-gethostbyaddre.aspx提供

答案 1 :(得分:8)

Jeremy的答案基于Reverse DNS,这是查找IP-&gt;主机名的常规编程方式。它依赖于为该服务器设置的PTR记录;这通常但并不总是设置为有用的东西。

例如查看,thedailywtf.com,你将得到74.50.106.245,但由于“245.106.50.74.in-addr.arpa”没有PTR记录,Dns.GetHostEntry()不会返回任何内容是有用的。

同样,许多服务器场只会为您提供一个通用的主机名,如123.45.67.89-dedicated.bigexamplehost.com。

您的信号正在做的不同,它是“被动DNS复制”。他们运行一些人们正在查询的DNS服务器,并记住查找过的每个主机名。然后,您可以通过返回的地址查询过去查找的记录。将74.50.106.245放入yougetsignal,您将获得一个主机名列表,这些主机名先前在人们查询时解析到dailywtf服务器,而不是与反向DNS PTR条目有关。

答案 2 :(得分:2)

反向DNS与您提出的内容不同(在同一服务器上托管哪些网站)。反向DNS通常无法按预期工作(请参阅bobince的回答)。

为了能够识别主机中的其他网站,您需要构建一个海量数据库并尽可能多地存储DNS记录,然后关联IP地址。

退房:http://www.domaintools.com/reverse-ip/

他们按照我说的方式这样做,这是获得准确结果的唯一方法。显然,需要时间,CPU,带宽和空间来关联和爬行/生成数据。