markus / KCOM / Common / DNSHelper.cs @ e52385b9
이력 | 보기 | 이력해설 | 다운로드 (977 Bytes)
1 | af22332b | ljiyeon | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Net; |
||
5 | using System.Net.NetworkInformation; |
||
6 | using System.Text; |
||
7 | using System.Threading.Tasks; |
||
8 | |||
9 | namespace KCOM.Common |
||
10 | { |
||
11 | public class DNSHelper |
||
12 | { |
||
13 | public static IPAddress GetDnsAdress() |
||
14 | { |
||
15 | NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); |
||
16 | |||
17 | foreach (NetworkInterface networkInterface in networkInterfaces) |
||
18 | { |
||
19 | if (networkInterface.OperationalStatus == OperationalStatus.Up) |
||
20 | { |
||
21 | IPInterfaceProperties ipProperties = networkInterface.GetIPProperties(); |
||
22 | IPAddressCollection dnsAddresses = ipProperties.DnsAddresses; |
||
23 | |||
24 | foreach (IPAddress dnsAdress in dnsAddresses) |
||
25 | { |
||
26 | return dnsAdress; |
||
27 | } |
||
28 | } |
||
29 | } |
||
30 | return null; |
||
31 | } |
||
32 | } |
||
33 | } |