DDNS use No-IP

Dependents:   TCPEchoClient-WIZwiki-W7500

Prerequisite

This is DDNS_NoIP Library. DDNS(Dynamic DNS) host name is linked up to the uesr's dynamic IP address. Whenever the IP changes a dynamic DNS client will send an update to No-IP with the current IP address and then No-IP propagates the DNS change to the internet within seconds.


DDNS Configuration

NoIP Site

https://www.noip.com/ /media/uploads/joon874/1.png

/media/uploads/joon874/14.png

Hardware Configuration

WIZwiki-W7500 Pin map

pin map


Software

DDNS

/* Set ID Pass and Hostname */
void userSetNoIP(char* idpass, char* hostname);

/* Upload DDNS IP Address */
void updateNoIP(void);

/* Check DDNS IP Address */
void checkIp(void);


Caution

Revision:
0:807cbe212e24
Child:
1:a5d5ddadd7e7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DDNSClient.cpp	Thu Oct 29 00:26:47 2015 +0000
@@ -0,0 +1,73 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "DDNSClient.h"
+#define DEBUG
+DDNSClient::DDNSClient() 
+{
+    noip_ddns = "dynupdate.no-ip.com";
+    noip_ddns_port = 80;    
+}
+DDNSClient::~DDNSClient()
+{
+  
+}
+void DDNSClient::updateNoIP(void)
+{
+    char buf[1024]={0,};
+
+#ifdef DEBUG
+    printf("Updating NoIP...\r\n");       
+#endif
+    while (DDNSupdate.connect(noip_ddns, noip_ddns_port) < 0) {
+    #ifdef DEBUG
+        printf("Unable to connect to (%s) on port (%d)\r\n", noip_ddns, noip_ddns_port);
+    #endif
+        wait(0.5);
+    } 
+#ifdef DEBUG
+    printf("Sended message to server :\r\n");
+#endif  
+    snprintf(buf, sizeof(buf), "GET /nic/update?hostname=%s&myip=%s HTTP/1.0\r\n", _hostname, _ip);                                                               
+    DDNSupdate.send_all(buf, strlen(buf));
+#ifdef DEBUG
+    printf("%s\r\n", buf);
+#endif
+    
+    snprintf(buf, sizeof(buf), "Host: dynupdate.no-ip.com\r\n"); //Write request                                                                 
+    DDNSupdate.send_all(buf, strlen(buf));
+#ifdef DEBUG
+    printf("%s\r\n", buf);
+#endif
+    
+    snprintf(buf, sizeof(buf), "Authorization: Basic %s\r\n", _idpass); //Write request                                                                 
+    DDNSupdate.send_all(buf, strlen(buf));
+#ifdef DEBUG
+    printf("%s\r\n", buf);
+#endif
+    
+    snprintf(buf, sizeof(buf), "User-Agent: mbed client/1.0 ricky@wiznet.co.kr\r\n\r\n"); //Write request                                                                 
+    DDNSupdate.send_all(buf, strlen(buf));
+#ifdef DEBUG
+    printf("%s\r\n", buf);
+#endif
+
+#ifdef DEBUG
+    printf("Received message from server :\r\n");
+#endif
+
+    wait(5.0);
+    memset(buf, 0, sizeof(buf));
+    DDNSupdate.receive_all(buf, sizeof(buf));
+#ifdef DEBUG
+    printf("%s", buf);
+#endif
+
+    DDNSupdate.close();
+    
+}
+void DDNSClient::userSetNoIP(char* idpass, char* hostname, char* ip)
+{
+    _hostname = hostname;
+    _ip = ip;
+    _idpass = idpass;
+}