using System.Net;
using System.Net.Sockets;
namespace GetIpByDomain
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
if(args.Length <= 0)
{
Console.Write("\nGetIpByDomain V1.0 by ∮明天去要饭 QQ:305725744\n");
Console.Write("Usage:\n");
Console.Write(" GetIpByDomain.exe <Domain>\n");
Console.Write("Example:\n");
Console.Write(" GetIpByDomain.exe Www.ToEmpire.Com");
}
else
{
string strDomain = args[0].ToString();
IPHostEntry hostEntry = Dns.Resolve(strDomain);
IPEndPoint ipEndPoint = new IPEndPoint( hostEntry.AddressList[0],0);
//这就是你想要的
string ipAddress = ipEndPoint.Address.ToString();
Console.Write(ipAddress);
}
}
}
}