代码
1 //可以通过比较 NetworkInterface 的 NetworkInterfaceType 筛选不需要的内容
2 NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();
3 foreach (NetworkInterface ni in nis)
4 {
5 PhysicalAddress pa = ni.GetPhysicalAddress();
6 string mac = pa.ToString();
7 }
8
9 string myHostName = Dns.GetHostName();
10 IPHostEntry ips = Dns.GetHostEntry(myHostName);
11 foreach (IPAddress ip in ips.AddressList)
12 {
13 string ipString = ip.ToString();
14 }
15