Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
syno:dsm6inst [2022/11/18 00:50] – [DDNS over Namecheap] Bernard Condrausyno:dsm6inst [2022/11/18 00:59] – [DDNS over Namecheap] Bernard Condrau
Line 20: Line 20:
  
 ===== DDNS over Namecheap ===== ===== DDNS over Namecheap =====
 +  * Add the host to be accessed with DDNS to your domain's //Advanced DNS --> Dynamic DNS// in Namecheap
   * Make sure you installed php-curl and php-xml in your [[deb11:apache#php_installation|Apache 2.4 and PHP 7/8]] installation   * Make sure you installed php-curl and php-xml in your [[deb11:apache#php_installation|Apache 2.4 and PHP 7/8]] installation
   * Add the following script to your webserver:<code><?php   * Add the following script to your webserver:<code><?php
 try { try {
         $url = 'https://dynamicdns.park-your-domain.com/update?host='.$_GET['host'].'&domain='.$_GET['domain'].'&password='.$_GET['password'].'&ip='.$_GET['ip'];         $url = 'https://dynamicdns.park-your-domain.com/update?host='.$_GET['host'].'&domain='.$_GET['domain'].'&password='.$_GET['password'].'&ip='.$_GET['ip'];
-        $req = curl_init(); + 
-        curl_setopt($req, CURLOPT_URL, $url); +        // with allow_url_fopen enabled 
-        curl_setopt($req, CURLOPT_RETURNTRANSFER, true); +        $output = file_get_contents($url); 
-        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml')); + 
-        $res = curl_exec($req); +        // with curl 
-        curl_close($req); +        //$req = curl_init(); 
-        $xml = new SimpleXMLElement(trim(str_replace("encoding=\"utf-16\"","",$res)));+        //curl_setopt($req, CURLOPT_URL, $url); 
 +        //curl_setopt($req, CURLOPT_RETURNTRANSFER, true); 
 +        //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml')); 
 +        //$output = curl_exec($req); 
 +        //curl_close($req); 
 + 
 +        $xml = new SimpleXMLElement(trim(str_replace("encoding=\"utf-16\"","",$output)));
         if ($xml->ErrCount > 0) {         if ($xml->ErrCount > 0) {
                 $error = $xml->errors[0]->Err1;                 $error = $xml->errors[0]->Err1;
Line 36: Line 43:
                         echo "nohost";                         echo "nohost";
                 } elseif (strcmp($error, "Passwords do not match") === 0) {                 } elseif (strcmp($error, "Passwords do not match") === 0) {
 +                        echo "badauth";
 +                } elseif (strcmp($error, "Passwords is empty") === 0) {
                         echo "badauth";                         echo "badauth";
                 } elseif (strcmp($error, "No Records updated. A record not Found;") === 0) {                 } elseif (strcmp($error, "No Records updated. A record not Found;") === 0) {
Line 50: Line 59:
   * Make sure the DDNS update call is allowed by your webserver. For apache, add this to the conf:<code><RequireAny>   * Make sure the DDNS update call is allowed by your webserver. For apache, add this to the conf:<code><RequireAny>
 Require expr "%{QUERY_STRING} =~ /your Namecheap DDNS password/" # allow the DDNS updater to run from the changed ip address Require expr "%{QUERY_STRING} =~ /your Namecheap DDNS password/" # allow the DDNS updater to run from the changed ip address
-Require forward-dns host.domain.tld # allow access from the DDNS domain name after updating the ip address</code>+Require forward-dns host.domain.tld # allow access from the DDNS domain name after updating the ip address 
 +</RequireAny></code>
   * Create a custom DDNS updater in Synology DSM with the following //Query URL//:<code>https://vps.condrau.com/html/ddns-namecheap.php?host=__USERNAME__&domain=__HOSTNAME__&password=__PASSWORD__&ip=__MYIP__</code>   * Create a custom DDNS updater in Synology DSM with the following //Query URL//:<code>https://vps.condrau.com/html/ddns-namecheap.php?host=__USERNAME__&domain=__HOSTNAME__&password=__PASSWORD__&ip=__MYIP__</code>
   * [[https://code-bude.net/2022/02/16/namecheap-com-ddns-in-synology-dsm-einrichten/|Namecheap.com DDNS in Synology DSM einrichten]]   * [[https://code-bude.net/2022/02/16/namecheap-com-ddns-in-synology-dsm-einrichten/|Namecheap.com DDNS in Synology DSM einrichten]]
 +  * [[https://www.namecheap.com/support/knowledgebase/article.aspx/29/11/how-to-dynamically-update-the-hosts-ip-with-an-http-request/|How to dynamically update the host's IP with an HTTP request?]]
  
 ===== Certificates ===== ===== Certificates =====