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
syno:dsm6inst [2022/11/17 22:01] Bernard Condrausyno:dsm6inst [2022/11/18 00:59] (current) – [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
 +  - Add the following script to your webserver:<code><?php
 +try {
 +        $url = 'https://dynamicdns.park-your-domain.com/update?host='.$_GET['host'].'&domain='.$_GET['domain'].'&password='.$_GET['password'].'&ip='.$_GET['ip'];
 +
 +        // with allow_url_fopen enabled
 +        $output = file_get_contents($url);
 +
 +        // with curl
 +        //$req = curl_init();
 +        //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) {
 +                $error = $xml->errors[0]->Err1;
 +                if (strcmp($error, "Domain name not found") === 0) {
 +                        echo "nohost";
 +                } elseif (strcmp($error, "Passwords do not match") === 0) {
 +                        echo "badauth";
 +                } elseif (strcmp($error, "Passwords is empty") === 0) {
 +                        echo "badauth";
 +                } elseif (strcmp($error, "No Records updated. A record not Found;") === 0) {
 +                        echo "nohost";
 +                } else {
 +                   echo "911 [".$error."]";
 +                }
 +        } else {
 +                echo "good";
 +        }
 +} catch (Exception $e) {
 +    echo "911 [".$e->getMessage()."]";
 +}</code>
 +  - 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 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>
   * [[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 =====