13. 5. 29.

C# DNS로 아이피 알아내기

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Net;
 
namespace cShapNslookup
{
    class Program
    {
        static void Main(string[] args)
        {
            string HostName = "";
             
            HostName = "www.naver.com";
            //실제 name 을 가져오기 위해 IPHostEntry을 이용
 
            IPHostEntry hostEntry = Dns.GetHostByName(HostName);
            Console.WriteLine("실제이름 : " + hostEntry.HostName + "");
            //IP 주소를 찾아서 출력함
 
            foreach (IPAddress ip in hostEntry.AddressList)
            {
                Console.WriteLine(ip.ToString());
            }
 
        }
    }
}

댓글 없음:

댓글 쓰기