728x90
반응형
[C#] DNS 서버 구하기
How to get DNS in C#
using System.Net;
using System.Net.NetworkInformation;
private void showDnsServer()
{
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
ArrayList dnsAddrList = new ArrayList();
foreach (NetworkInterface adapter in adapters)
{
IPInterfaceProperties adapterProperties = adapter.GetIPProperties();
if (adapter.OperationalStatus == OperationalStatus.Up & adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
IPAddressCollection dnsAddres = adapterProperties.DnsAddresses;
foreach (IPAddress dns in dnsAddres)
{
dnsAddrList.Add(dns.ToString());
}
}
}
string msg = "DNS : " + dnsAddrList[0] + "\r\n" + "DNSSub : " + dnsAddrList[1];
MessageBox.Show(msg,"info",MessageBoxButton.OK, MessageBoxIcon.Information);
return;
}
반응형
'Programming > C#' 카테고리의 다른 글
[C#] 비밀번호 공백 체크 (0) | 2021.04.13 |
---|---|
[C#] SubnetMask 구하기 (0) | 2019.08.30 |
[C#] Gateway 구하기 (0) | 2019.08.28 |
[C#] 로컬 IP 주소 구하기 (0) | 2019.08.27 |
[C#] 수행시간 구하기 (0) | 2018.08.21 |
댓글