IPHostEntry iphost = Dns.GetHostEntry(txtDNS.Text);//解析并返回IPHostEntry对象
foreach (IPAddress ip in iphost.AddressList)//遍历IP地址
{
string ipaddress = ip.ToString();//ip地址
lstIP.Items.Add(ipaddress);//添加到ListBox控件中
}
txtHostName.Text = iphost.HostName;//获取主机的DNS名称
04-21 04:23