.NET에서 DDNS를 구축 할수 있는 클래스나 함수를 제공하나요? RRS feed

  • 질문

  • 안녕하세요?

    다름이 아니라 .NET에서 DDNS를 구축 할 수 있는 클래스나 함수가 존재 하는지 궁금하군요

    찾아보니 DNS 서버에 쿼리해서 IP로 DNS 네임이나 DNS네임으로 IP를 가져올 수 있는 함수는 존재 하는데

    DNS 서버에 쿼리하여 IP를 업데이트 시키는 함수나 클래스는 없는 듯 하여 질문 올립니다.

    혹시 DNS 서버에 쿼리하여 IP를 업데이트 시킬수 있는 함수나 클래스가 있으면 알려주시면 고맙겠습니다.

    2011년 3월 10일 목요일 오전 5:36

모든 응답

  • DynDns Update with c# client
    다음과 같이 해보세요.
    DynDnsUpdateResult는 구조체로 대충 하나 만드시면 될듯...
    아니면 string형으로 "성공","실패" 리턴 받으면 될 듯 합니다.
    행운을 빕니다. 
      public DynDnsUpdateResult UpdateIP(IPAddress ip)
       byte[] data = new byte[1024];
       string response = "";
       int count;
       // Syntax zum Aufruf:
       Socket socket = new Socket(AddressFamily.InterNetwork,
       IPHostEntry host = System.Net.Dns.Resolve("");
       socket.Connect((EndPoint)(new IPEndPoint(host.AddressList[0], 80)));
       if (!socket.Connected)
       throw new Exception("Can´t connect to dyndns service");
       string request = "GET /nic/update?" +
       "system=dyndns" +
       "&hostname=" + mDomain +
       "&myip=" + ip.ToString() +
       "&wildcard=" + (mWildcard ? "ON" : "OFF") +
       "&offline=NO " +
       "HTTP/1.1\r\n" +
       "Host:\r\n" +
       "Authorization: Basic " +
       System.Convert.ToBase64String(ASCIIEncoding.ASCII. GetBytes(mUsername + ":" +
       mPassword)) + "\r\n" +
       "User-Agent: .net dyndns client\r\n\r\n";
       count = socket.Send(System.Text.UnicodeEncoding.ASCII.GetBytes(request));
       while((count = socket.Receive(data)) != 0) // Antwort von Server
        response += System.Text.ASCIIEncoding.ASCII.GetString(data, 0, count);
       response = response.Substring(response.IndexOf("\r\n\r\n") + 4); // Html Header entfernen
       switch (response.Substring(0, response.IndexOf(" ")).ToLower())
        case "good":
         // The update was successful, and the hostname is now updated
         return DynDnsUpdateResult.UpdatedIp;
        case "nochg":
         // The update changed no settings, and is considered abusive.
         //Additional nochg updates will cause the hostname to become blocked
         return DynDnsUpdateResult.NoUpdateSameIp;
        case "badsys":
         throw new Exception("The system parameter given is not valid. Valid system parameters are dyndns, statdns and custom");
        case "badagent":
         throw new Exception("The user agent that was sent has been blocked for not following these specifications or no user agent was specified");
        case "badauth":
         throw new Exception("The username or password specified are incorrect");
        case "!donator":
         throw new Exception("An option available only to credited users (such as offline URL) was specified, but the user is not a credited user");
        case "notfqdn":
         throw new Exception("The hostname specified is not a fully-qualified domain name (not in the form or");
        case "nohost":
         throw new Exception("The hostname specified does not exist (or is not in the service specified in the system parameter)");
        case "!yours":
         throw new Exception("The hostname specified exists, but not under the username specified");
        case "abuse":
         throw new Exception("The hostname specified is blocked for update abuse");
        case "numhost":
         throw new Exception("Too many or too few hosts found");
        case "dnserr":
         throw new Exception("DNS error encountered");
        case "911":
         throw new Exception("There is a serious problem on our side, such as a database or DNS server failure. The client should stop updating until notified via the status page that the service is back up.");
         throw new Exception("Unknown result from dyndns service");



    잘 되시면 채택해주시는 센스 ^^;

    • 편집됨 GoldrushKoreaMVP 2011년 6월 14일 화요일 오전 7:31 보기좋게..
    2011년 6월 14일 화요일 오전 7:29