网络DNS域名转换成IP地址
3,475 views
0
网络DNS域名转换成IP地址(完整代码,测试通过)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace DNS2IP
{
class Program
{
// 主函数,入口函数
static void Main(string[] args)
{
string strDNS="www.mimvp.com";
string strIP = GetIP(strDNS);
Console.WriteLine(strIP);
Console.ReadLine();
}
// 利用域名,获取IP地址
public static string GetIP(string strDNS)
{
IPHostEntry hostEntry = Dns.GetHostEntry(strDNS);
IPEndPoint ipEndPoint = new IPEndPoint(hostEntry.AddressList[0], 0);
string ipAddress = ipEndPoint.Address.ToString();
return ipAddress;
}
}
}
原文: 网络DNS域名转换成IP地址
参考推荐:
版权所有: 本文系米扑博客原创、转载、摘录,或修订后发表,最后更新于 2018-03-27 08:19:08
侵权处理: 本个人博客,不盈利,若侵犯了您的作品权,请联系博主删除,莫恶意,索钱财,感谢!
转载注明: 网络DNS域名转换成IP地址 (米扑博客)