C# 反向 IP 域检查?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/716748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Reverse IP Domain Check?
提问by
There is a website which you can query with a domain and it will return a list of all the websites hosted on that IP. I remember there being a method in C# that was something like ReturnAddresses or something of that sort. Does anyone have any idea how this is done? Quering a hostname or IP and having returned a list of hostnames aka other websites hosted on the same server?
有一个网站,您可以使用域进行查询,它将返回该 IP 上托管的所有网站的列表。我记得在 C# 中有一种方法,类似于 ReturnAddresses 或类似的东西。有谁知道这是如何完成的?查询主机名或 IP 并返回主机名列表,即同一服务器上托管的其他网站?
the website is: http://www.yougetsignal.com/tools/web-sites-on-web-server/
该网站是:http: //www.yougetsignal.com/tools/web-sites-on-web-server/
采纳答案by Jeremy Stanley
After reading the comments, bobince is definitely right and these 2 should be used in tandem with each other. For best results you should use the reverse DNS lookup here as well as to use the passive DNS replication.
阅读评论后,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);
}
courtesy of http://www.eggheadcafe.com/community/aspnet/2/83624/system-dns-gethostbyaddre.aspx
礼貌http://www.eggheadcafe.com/community/aspnet/2/83624/system-dns-gethostbyaddre.aspx
回答by bobince
Jeremy's answer is based around Reverse DNS, which is the normal programmatical way to look up IP->hostname. It relies an a PTR record being set up for that server; this is often but not always set up to something useful.
Jeremy 的回答基于反向 DNS,这是查找 IP->主机名的正常编程方式。它依赖于为该服务器设置的 PTR 记录;这通常但并不总是设置为有用的东西。
For example look up, thedailywtf.com and you'll get 74.50.106.245, but since there is no PTR record for “245.106.50.74.in-addr.arpa”, Dns.GetHostEntry() won't return anything useful.
例如,查找 thedailywtf.com,您将得到 74.50.106.245,但由于“245.106.50.74.in-addr.arpa”没有 PTR 记录,因此 Dns.GetHostEntry() 不会返回任何有用的信息。
Similarly, many server farms will just give you a generic hostname like 123.45.67.89-dedicated.bigexamplehost.com.
同样,许多服务器场只会给你一个通用的主机名,比如 123.45.67.89-dedicated.bigexamplehost.com。
What yougetsignal is doing is different, it's “Passive DNS Replication”. They run some DNS servers people are querying, and remember every hostname that was looked up. Then you can query their records of past lookups by the address that was returned. Put 74.50.106.245 into yougetsignal and you'll get a list of hostnames that previously resolved to the dailywtf server when people queried them, not anything to do with the Reverse DNS PTR entry.
yougetsignal 所做的是不同的,它是“被动 DNS 复制”。他们运行一些人们正在查询的 DNS 服务器,并记住所查找的每个主机名。然后您可以通过返回的地址查询他们过去查找的记录。将 74.50.106.245 放入 yougetsignal 中,您将获得之前在人们查询时解析到 Dailywtf 服务器的主机名列表,与反向 DNS PTR 条目无关。
回答by dr. evil
Reverse DNS is not as same as what you asking (which sites hosted on the same server). Reverse DNS generally won't work as you expect (see bobince's answer).
反向 DNS 与您询问的不同(哪些站点托管在同一台服务器上)。反向 DNS 通常不会像您预期的那样工作(请参阅 bobince 的回答)。
To able to identify other websites in a host, you need to build a massive database and store as much as DNS record as you can, then correlate IP addresses.
为了能够识别主机中的其他网站,您需要构建一个庞大的数据库并尽可能多地存储 DNS 记录,然后关联 IP 地址。
Check out : http://www.domaintools.com/reverse-ip/
退房:http: //www.domaintools.com/reverse-ip/
They are doing this as the way I said, that's only way to get an accurate results. Obviously it takes time, CPU, bandwith and space to correlate and crawl/generate that data.
他们就像我说的那样这样做,这是获得准确结果的唯一方法。显然,关联和抓取/生成该数据需要时间、CPU、带宽和空间。