Giter Club home page Giter Club logo

easyddns's Introduction

EasyDDNS


Notice: This library has been deprecated and is not going to be maintained.


     


An easy to use DDNS Update Client library for ESP8266 & ESP32.

EasyDDNS Library can be implemented in your major projects as a sidekick. It is independent and does not interfare with rest of your code.

Supported DDNS Providers:

  • DuckDNS
  • No-ip
  • DynDNS
  • Dynu
  • ENom
  • all-inkl
  • selfhost.de
  • strato
  • freemyip
  • afraid.org
  • OVH.com

If you don't know what's DDNS, then you can find more info about DDNS here: WiKipedia


How to Install

(Best Method) Directly Through Arduino IDE

Go to Sketch > Include Library > Library Manager > Search for "EasyDDNS" > Install

Manual Install

For Windows: Download the Repository and extract the .zip in Documents>Arduino>Libraries>{Place "EasyDDNS" folder Here}

For Linux: Download the Repository and extract the .zip in Sketchbook>Libraries>{Place "EasyDDNS" folder Here}

Manually through IDE

Download the Repository, Go to Sketch>Include Library>Add .zip Library> Select the Downloaded .zip File.


Dependencies

For ESP8266:

For ESP32:


Example

#if defined(ESP8266)
  #include "ESP8266WiFi.h"
  #include "ESP8266HTTPClient.h"
#elif defined(ESP32)
  #include "WiFi.h"
  #include "HTTPClient.h"
#endif

#include <EasyDDNS.h>

const char * ssid = "your-ssid";
const char * password = "your-password";

WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println(WiFi.localIP()); // Print the IP address
  server.begin();

  /*
    List of supported DDNS providers:
    - "duckdns"
    - "noip"
    - "dyndns"
    - "dynu"
    - "enom"
    - "all-inkl"
    - "selfhost.de"
    - "dyndns.it"
    - "strato"
    - "freemyip"
    - "afraid.org"
  */
  EasyDDNS.service("duckdns");

  /*
    For DDNS Providers where you get a token:
      Use this: EasyDDNS.client("domain", "token");
    
    For DDNS Providers where you get username and password: ( Leave the password field empty "" if not required )
      Use this: EasyDDNS.client("domain", "username", "password");
  */
  EasyDDNS.client("12345.duckdns.org", "token"); // Enter your DDNS Domain & Token

  // Get Notified when your IP changes
  EasyDDNS.onUpdate([&](const char* oldIP, const char* newIP){
    Serial.print("EasyDDNS - IP Change Detected: ");
    Serial.println(newIP);
  });
}

void loop() {
  // Check for new public IP every 10 seconds
  EasyDDNS.update(10000);
}

Support Me

You can always buy me a coffee :) , It supports my work and in return you get to keep up-to-date version of my libraries.


easyddns's People

Contributors

ayushsharma82 avatar cjmccjmccjmc avatar comertial avatar gspin96 avatar hacsko-adam avatar khoih-prog avatar kolod avatar leobel96 avatar patteb avatar per1234 avatar servuc avatar vivian-ng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easyddns's Issues

Support for OVH

Hello,
I would like to request the support for the OVH system the link to update and this https://www.ovh.com/nic/update?system=dyndns&hostname=$HOST&myip=$CURRENT_IP

To update it asks for an id and a password currently I use a script and send a curl command like this RES = curl --user "$LOGIN:$PASSWORD" "https://www.ovh.com/nic/update?system=dyndns&hostname=$HOST&myip=$CURRENT_IP"
Thank's

http.begin need WiFiClient

By using example code I got this exception error ( Board ESP01s / DDNS dynu )

Exception 9: LoadStoreAlignmentCause: Load or store to an unaligned address
PC: 0x40217e14: HTTPClient::connected() at C:\Data\Programs\arduino\Portable\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 475
EXCVADDR: 0x00000247

Decoding stack results
0x4020d05b: String::reserve(unsigned int) at C:\Data\Programs\arduino\Portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\WString.cpp line 146
0x40204ec0: HTTPClient::disconnect(bool) at C:\Data\Programs\arduino\Portable\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 434
0x40205c5c: HTTPClient::end() at C:\Data\Programs\arduino\Portable\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266HTTPClient\src\ESP8266HTTPClient.cpp line 425
0x402049e2: EasyDDNSClass::update(unsigned long, bool) at C:\Data\Documents\Man\Cloud\arduino\Projects\libraries\EasyDDNS\EasyDDNS.cpp line 48
0x40100494: millis() at C:\Data\Programs\arduino\Portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_wiring.cpp line 188
0x4020866d: esp8266::MDNSImplementation::MDNSResponder::_process(bool) at C:\Data\Programs\arduino\Portable\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266mDNS\src\LEAmDNS_Control.cpp line 90
0x40203360: ESP8266WiFiSTAClass::status() at C:\Data\Programs\arduino\Portable\packages\esp8266\hardware\esp8266\2.7.4\libraries\ESP8266WiFi\src\ESP8266WiFiSTA.cpp line 634
0x40201840: NTPClient::update() at C:\Data\Documents\Man\Cloud\arduino\Projects\libraries\NTPClient\NTPClient.cpp line 96
0x40201464: loop() at C:\Data\Documents\Man\Cloud\arduino\Projects\DDNS_esp01/DDNS_esp01.ino line 141
0x4010039c: ets_post(uint8, ETSSignal, ETSParam) at C:\Data\Programs\arduino\Portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 177
0x4020e008: loop_wrapper() at C:\Data\Programs\arduino\Portable\packages\esp8266\hardware\esp8266\2.7.4\cores\esp8266\core_esp8266_main.cpp line 197

This because new ESP8266httpClient has changed as lrmoreno007 create a pullrequest sinse 16 Nov 2020

Here is how to modify code.

add between Line 26 and 27
WiFiClient client;

Line 38 from
http.begin("http://ipv4bot.whatismyipaddress.com/");
to
http.begin(client, "http://ipv4bot.whatismyipaddress.com/");

Line 85 from
http.begin(update_url);
to
http.begin(client, update_url);

duckdns not updateing

I installed EasyDDNS on a esp8266 a few years ago and assumed that it was updating.
My ISP changed my IP address when I installed a new router and I discovered that it was not updating.
I set it up as described in readme file.
#include <EasyDDNS.h>
Inside void setup(void)
EasyDDNS.service("duckdns");
EasyDDNS.client("My subdomain.duckdns.org", "My token");
inside void loop(void)
EasyDDNS.update(1000);//every 10 seconds
Any ideas?

Enhancement request: Simpler multiple DDNS support

I might have a need to enable multiple DDNS services together.

Currently, I can achieve it by multiple objects of EasyDDNSClass and initializing all of them separately.
However, a lot of the code is common:

  1. Update time expiry
  2. Getting the public IP
    etc

It will be useful if we could keep the common members (e.g. new_ip; old_ip;) and methods as static to class and update only once, even if there are many services defined.

Also, from a usability point of view, It will be very useful if (in addition to the current single service support), we can init the library via an array or something.

Something like:

String myServices[] = ["noip", "duckdns", "duckdns"];
EasyDDNS.service(myServices);

Error -1 when calling dynupdate.no-ip.com

Hello
I have been trying for many days to get http to not respond -1 using the DDNS_client.ino example.
I have modified the source (EasyDDNS.cpp) to know if the call to http.begin was correct.
`int httpCode = http.GET();

Serial.println(String(httpCode)+" desde ddns.cpp: "+update_url);

if (httpCode == 200) {
`
If I do a copy/paste from monitor in firefox it correctly updates the ip in no_ip.com.
The call to "ifconfig.me/ip" resolves it perfectly and returns the real ip.
I am using an ESP01S (8266) with all the updated libraries.
IDE v. 1.8.19
ESP8266 v. 3.1.2

Greetings

how to use it.

hi , i am working on esp8266 projects, found your library. it is quite interesting.
But i am not be able to use it.
If i install DUCKDNS_client example into esp8266, whats next then.
how to access it via web browser or android app.
my code is :

EasyDDNS.service("duckdns");
EasyDDNS.client("esp.duckdns.org","1234567");

i tried to access it in web browser but no response.
please guide. thanks

Not working when setting a static IP for port forwarding to expose Web server on internet

Hi.

First let me thank you for your great library and support to it. It is really very useful.

My problem seems that setting a static IP on the app it does not let the EasyDDNS update the Duch DNS.

The issue I'm facing is that I cannot integrate it on my NodeMCU lolin v3 (ESP8266) application.
I have running on oneNodeMCU a Web server. I need to access this from the internet. So I use a port forwarding on my Router from the outside to the static IP on the nodeMCU on port 80. Then I have a DuckDNS account that I use your library to get updated.

On my router I set:
Application | Protocol | Source Port | Destination IP | Destination port
myApp| TCP+UDP | 80 | 192.168.1.230 | 80

If I run another standalone app (no Web server) with your EasyDDNS on a second NodeMCU it runs perfectly and updates the public IP address on the Duck DNS without any problems. It works!

My problem seems that setting a static IP on the app it does not let the EasyDDNS update the Duch DNS.
So I'm using 2 NodeMCUs. I would like to integrate all the code on one NodeMCU only. Any suggestions?

This is some of the code on my first NodeMCU

#include "ESP8266WiFi.h"
#include "ESP8266HTTPClient.h"

const char* ssid = "SSID";
const char* password = "PASSWORD";
IPAddress static_IP(192, 168, 1, 230); // Set your Static IP address
IPAddress gateway(192, 168, 1, 1);    // Set your Gateway IP address
IPAddress subnet(255, 255, 255, 0);   // Subnet Mask

WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  delay(10);
  // Connect to WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.config(static_IP, gateway, subnet);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

  // Start the server
  server.begin();
  Serial.println("Server started");

  // Print the IP address on serial monitor
  Serial.print("Use this URL to connect: ");
  Serial.print("http://");    //URL IP to be typed in mobile/desktop browser
  Serial.print(WiFi.localIP());
  Serial.println("/");
}

This is the code on my second NodeMCU:

#include "ESP8266WiFi.h"
#include "ESP8266HTTPClient.h"
#include <EasyDDNS.h>

const char * ssid = "SSID";
const char * password = "PASSWORD";

WiFiServer server(80);

void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("\r\n");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println(WiFi.localIP()); // Print the IP address
  server.begin();

  EasyDDNS.service("duckdns");

  EasyDDNS.client("myAPP.duckdns.org", "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"); // Enter your DDNS Domain & Token
  
  // Get Notified when your IP changes
  EasyDDNS.onUpdate([&](const char* oldIP, const char* newIP){
    Serial.print("EasyDDNS - IP Change Detected: ");
    Serial.println(newIP);
  });
}

void loop() {
  // Check for new public IP every 10 seconds
  EasyDDNS.update(10000);
  }

Many thanks
Regards
Pedro

No-ip not updating whilst using a mobile wifi dongle

I am using a ESP32 camera module configured as a security camera. This is intended to be located in my garage, and gains its internet connection via a mobile hotspot.

The code is set up so connect to a variety of wifi SSID's, so the ESP32 will connect at home, or when in the garage.

When the ESP32 boots on my home wifi, it updates no-ip no problem, I can see this on my account, and the text output from the serial port confirms this.

When the ESP32 is connected via the mobile hotspot, it fails to update, nor are any further messages shown.

I am assuming this was in relation to the previous issue logged about IPV4 addresses, but I thought that had been fixed in the 1.8.0 library (which is what I am using).

I have checked, and my mobile provider does not issue IPV6 addresses, and I do not have any other either inbound or outbound connectivity issues through the mobile hotspot firewall.

Please can you advise if there is a workaround, or an update in the pipeline that may fix this?

Many thanks.
EasyDDNS Issue.docx

DDNS update IP successful but cannot access TCP server

I combined the example from EasyDDNS and https://randomnerdtutorials.com/esp32-web-server-arduino-ide/.

The web page can access from local IP but cannot be accessed from DDNS hostname.

Here is my code:

#include "WiFi.h"
#include "HTTPClient.h"

#include <EasyDDNS.h>

const char * ssid = "ssid";
const char * password = "pw";

WiFiServer server(80);
// Variable to store the HTTP request
String header;

// Auxiliar variables to store the current output state
String output26State = "off";
String output27State = "off";

// Assign output variables to GPIO pins
const int output26 = 26;
const int output27 = 27;

// Current time
unsigned long currentTime = millis();
// Previous time
unsigned long previousTime = 0;
// Define timeout time in milliseconds (example: 2000ms = 2s)
const long timeoutTime = 2000;

void setup() {
Serial.begin(115200);
IPAddress ip(192,168,1,20);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);
IPAddress primaryDNS(8, 8, 8, 8);
WiFi.config(ip, gateway, subnet,primaryDNS);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(WiFi.localIP()); // Print the IP address
server.begin();

/*
List of supported DDNS providers:
- "duckdns"
- "noip"
- "dyndns"
- "dynu"
- "enom"
- "all-inkl"
- "selfhost.de"
- "dyndns.it"
- "strato"
- "freemyip"
- "afraid.org"
*/
EasyDDNS.service("noip");

/*
For DDNS Providers where you get a token:
Use this: EasyDDNS.client("domain", "token");

For DDNS Providers where you get username and password: ( Leave the password field empty "" if not required )
  Use this: EasyDDNS.client("domain", "username", "password");

*/

EasyDDNS.client("myhostname.zapto.org", "myname", "mypw");
EasyDDNS.update(1000);
// Get Notified when your IP changes
EasyDDNS.onUpdate([&](const char* oldIP, const char* newIP){
Serial.print("EasyDDNS - IP Change Detected: ");
Serial.println(newIP);
});
}

void loop() {
// Check for new public IP every 10 seconds
WiFiClient client = server.available();
uint8_t data[12];

if (client) { // If a new client connects,
currentTime = millis();
previousTime = currentTime;
Serial.println("New Client."); // print a message out in the serial port
String currentLine = ""; // make a String to hold incoming data from the client
while (client.connected() && currentTime - previousTime <= timeoutTime) { // loop while the client's connected
currentTime = millis();
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
Serial.write(c); // print it out the serial monitor
header += c;
if (c == '\n') { // if the byte is a newline character
// if the current line is blank, you got two newline characters in a row.
// that's the end of the client HTTP request, so send a response:
if (currentLine.length() == 0) {
// HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
// and a content-type so the client knows what's coming, then a blank line:
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();

        // turns the GPIOs on and off
        if (header.indexOf("GET /26/on") >= 0) {
          Serial.println("GPIO 26 on");
          output26State = "on";
          digitalWrite(output26, HIGH);
        } else if (header.indexOf("GET /26/off") >= 0) {
          Serial.println("GPIO 26 off");
          output26State = "off";
          digitalWrite(output26, LOW);
        } else if (header.indexOf("GET /27/on") >= 0) {
          Serial.println("GPIO 27 on");
          output27State = "on";
          digitalWrite(output27, HIGH);
        } else if (header.indexOf("GET /27/off") >= 0) {
          Serial.println("GPIO 27 off");
          output27State = "off";
          digitalWrite(output27, LOW);
        }
        
        // Display the HTML web page
        client.println("<!DOCTYPE html><html>");
        client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
        client.println("<link rel=\"icon\" href=\"data:,\">");
        // CSS to style the on/off buttons 
        // Feel free to change the background-color and font-size attributes to fit your preferences
        client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
        client.println(".button { background-color: #4CAF50; border: none; color: white; padding: 16px 40px;");
        client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}");
        client.println(".button2 {background-color: #555555;}</style></head>");
        
        // Web Page Heading
        client.println("<body><h1>ESP32 Web Server</h1>");
        
        // Display current state, and ON/OFF buttons for GPIO 26  
        client.println("<p>GPIO 26 - State " + output26State + "</p>");
        // If the output26State is off, it displays the ON button       
        if (output26State=="off") {
          client.println("<p><a href=\"/26/on\"><button class=\"button\">ON</button></a></p>");
        } else {
          client.println("<p><a href=\"/26/off\"><button class=\"button button2\">OFF</button></a></p>");
        } 
           
        // Display current state, and ON/OFF buttons for GPIO 27  
        client.println("<p>GPIO 27 - State " + output27State + "</p>");
        // If the output27State is off, it displays the ON button       
        if (output27State=="off") {
          client.println("<p><a href=\"/27/on\"><button class=\"button\">ON</button></a></p>");
        } else {
          client.println("<p><a href=\"/27/off\"><button class=\"button button2\">OFF</button></a></p>");
        }
        client.println("</body></html>");
        
        // The HTTP response ends with another blank line
        client.println();
        // Break out of the while loop
        break;
      } else { // if you got a newline, then clear currentLine
        currentLine = "";
      }
    } else if (c != '\r') {  // if you got anything else but a carriage return character,
      currentLine += c;      // add it to the end of the currentLine
    }
  }
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");

}
EasyDDNS.update(10000);
}

Adding to EspEasy

Hi, any chance of adding this to EspEasy ? I am looking for a way to update the IP with EspEasy. Can you make a plugin out of it ?

Option to use local IP to send to DDNS service

Propose to support a new use case where the local IP address is uploaded into selected DDNS. This will allow use of this library so android devices can find local machines without using mDNS.

Happy do make a pull request to implement.

please add selfhost.de

Hi thanks for your cool work, can you please selfhost.de dnydns service? many thanks and regards

ipv4.whatismyipaddress fails

According to the whatismyipaddress.com website, they are no longer supporting the API for ipv4bot.whatismyipaddress.com

No-IP not working, httpCode -1

I am doing some tests with the library for No-IP. For this, I have added two Serial.println() in EasyDDNS.cpp, one for the variable "update_url" and other for variable "httpCode" when sending the new IP.

httpCode is always -1, and the url from "update_url" is correct, it works in browser.

Any idea what may be happening? I am using Arduino 1.8.9, and ESP8266 3.0.2.

Thank you.

Integration of all-inkl DynDns

Hey, if possible, please integrate the (in Germany VERY popular) paid DynDns service "all-inkl".

The Update URL reads:
https://USERNAME:[email protected]/?myip=000.000.000.000

where USERNAME and PASSWORD must be specified by the user. 000.000.000.000 must be replaced with the IP address (accepts IP4 or IP6 format).

Not updating IP using dynu dns

Hi, I’ve used your code for several years with success. However over the the last week, the nodemcu won’t update IP on dynu dns.
Kindly advise

EasyDDNS.cpp httpCode -1

after some time that the library was working i realized that when the library tries to get the public ip i get an httpCode equal to -1!!
i am trying to find what causes this problem but i am not able to find anything...
i even tried to get my ip from ipify but i seem to get back the same error code! (i tried apify because they state in their site that you can do as many requests as you like instead of the whats my ip.. my thought was that i was blocked but as it seems thats not the case)

any help would be appreciated!

Not establishing connection to no-ip.org

Hi,

I'm trying to use this on my ESP8266 but I'm finding that, even thought the example code works and it seems like a connection is established, when accessing no-ip.org I see that the ip has not been updated in the last weeks.

Could I get some assistance with this problem? For starts, I've tried setting up the username as the email address as well as the username defined under https://my.noip.com/#!/account but neither seemed to work. Which one should it be expecting to work?
Where else should I be looking for the problem?
How can I pull some logs to figure out the problem?

Thank you,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.