如何将IP地址转换为域名? [英] How to convert IP Address to Domain name ?
本文介绍了如何将IP地址转换为域名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好b $ b
如何将服务器URL IP地址转换为asp.net中的域名,c#?
Hi
How to convert server URL IP Address to Domain name in asp.net,c#?
推荐答案
哪一个?可以从一个IP地址托管多个域。
您可以尝试:
Which one? A number of domains can be hosted from a single IP address.
You can try this:
IPAddress url = IPAddress.Parse("2.100.56.197");
IPHostEntry iphe = Dns.GetHostEntry(url);
Console.WriteLine(iphe.HostName);
但很有可能它在很多情况下不起作用。
But there is a good chance it won't work in a lot of cases.
请查看以下链接
www.sourcecodester.com/article/net/converting-domain-names-ip-addresses.html [ ^ ]
我认为这就是你要找的东西。
快乐编程
Please review the following link
www.sourcecodester.com/article/net/converting-domain-names-ip-addresses.html[^]
I think this is what you are looking for.
Happy Programming
// Get Ip Address from DomainName
static void GetIPAddress(string hostname)
{
IPAddress[] ipAddr = Dns.GetHostAddresses(hostname);
Console.WriteLine("GetHostAddresses({0}) :", hostname);
foreach (IPAddress ip in ipAddr)
{
Console.WriteLine(ip);
}
}
// Get HostName from IPAddress
static void GetDomainName(string ipaddress)
{
IPHostEntry hostEntry = Dns.GetHostEntry(ipaddress);
Console.WriteLine("DNS name : " + hostEntry.HostName);
//Aliases if any
String[] aliases = hostEntry.Aliases;
for (int i = 0; i < aliases.Length; i++)
{
Console.WriteLine("Alias: " + aliases[i]);
}
}
你也可以从域名检查ip adderess和来自本网站的IP地址的域名 WhoisXY.com
这篇关于如何将IP地址转换为域名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文