解决IP地址(INT)来命名
问题描述:
可能重复:
How to get domain name from Given IP in C#?解决IP地址(INT)来命名
我如何转换IP地址INT格式字符串格式。 例如,我有这个IP地址在int格式,173.194.38.138
,我想转换为字符串www.rugadingku.blogspot.com
。我看到很多关于如何将ip字符串转换为int的示例,但是不能将int转换为字符串。
答
试试这个:没有测试
访问http://www.dijksterhuis.org/converting-an-ip-address-to-a-hostname-and-back-with-c/
// Map an IP address to a hostname
IPHostEntry IpToDomainName = Dns.GetHostEntry("209.85.173.99");
Console.WriteLine("DomainName: {0}", IpToDomainName.HostName);
也试试这个:
public static string getDNSName(string myIP)
{
System.Net.IPHostEntry ip = System.Net.Dns.GetHostByAddress(myIP);
return ip.HostName;
}
答
您可以使用此代码的IP地址转换为主机名:
IPHostEntry IpToDomainName = Dns.GetHostEntry("173.194.38.138");
string hostname =IpToDomainName.HostName;
你也可以用这样的方式:
System.Net.IPHostEntry ip = System.Net.Dns.GetHostByAddress("173.194.38.138");
string hostname = ip.HostName;
好,你需要建立一个[查找表(http://en.wikipedia.org/wiki/Lookup_table) – BrOSs
你知道一个IP可以在许多主机*享,对吗? –
http://*.com/questions/3252845/how-to-get-domain-name-from-given-ip-in-c – Habib