프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

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
}
클립보드 이미지 추가 (최대 크기: 500 MB)