Giter Club home page Giter Club logo

synologyddnscloudflaremultidomain's Introduction

Synology Dynamic DNS with Cloudflare for both multidomains and subdomains

Documentation website: https://mrikirill.github.io/SynologyDDNSCloudflareMultidomain/

Table of contents

What is new

  • πŸ†• New hostname input format: subdomain1.mydomain.com|subdomain2.mydomain.com (each domain is separated: |) used to be with --- separator
  • πŸ†• Hostname input uses a new source of data (account) and support 256 symbols limit (DSM UI limit)
  • πŸ†• Autodetect IPv4 and IPv6 addresses
  • πŸ†• Optimised request to Cloudflare API
  • πŸ†• Installer script

What this script does

  • A PHP script for Synology DSM (and potentially Synology SRM devices) adding support for Cloudflare to Network Centre > Dynamic DNS (DDNS).
  • Supports single domains, multidomains, subdomains and regional domains, or any combination thereof (example: dev.my.domain.com.au, domain.com.uk etc)
  • πŸ†• Easy installation process (added auto install script)
  • Based on CloudFlare API v4
  • Supports dual stack IPv4 and IPv6

Before you begin

Before starting the installation process, make sure you have (and know) the following information, or have completed these steps:

  1. Cloudflare credentials:

    a. Know your Cloudflare account username (or register for an account if you're new to Cloudflare); and

    b. Have your API key - no need to use your Global API key! (More info: API keys).

    image

    c. Create a API key with following (3) permissions:

    Zone > Zone.Settings > Read
    Zone > Zone > Read
    Zone > DNS > Edit

    The affected zone ressouces have to be (at least):

    Include > All zones from an account > <domain>

  2. DNS settings:

    Ensure the DNS A record(s) for the domain/zone(s) you wish to update with this script have been created (More information: Managing DNS records).

    Your DNS records should appear (or already be setup as follows) in Cloudflare:

    (Note: Having Proxied turned on for your A records isn't necessary, but it will prevent those snooping around from easily finding out your current IP address)

    image

  3. SSH access to your Synology device:

If you haven't setup this access, see the following Synology Knowledge Base article: [How can I sign in to DSM/SRM with root privilege via SSH?[(https://kb.synology.com/en-id/DSM/tutorial/How_to_login_to_DSM_with_root_permission_via_SSH_Telnet)

  1. SRM users: Knowledge of vi:

vi is the only text editor available within the Busybox environment available at the SSH command line on devices running SRM.

For assistance with vi commands, see: Basic vi commands

How to install

  1. SSH with root privledges on your supported device:

    a. For DSM Users:

    Navigate to Control Panel > Terminal & SNMP > Enable SSH service

    b. For SRM users:

    Navigate to Control Panel > Services > System Services > Terminal > Enable SSH service

    image

  2. Connect via SSH: Connect to your supported device via SSH and execute command

  • πŸ†• For DSM Users

    wget https://raw.githubusercontent.com/mrikirill/SynologyDDNSCloudflareMultidomain/master/install.sh -O install.sh && sudo bash install.sh
    
  • πŸ†• For SRM Users Note: Ensure you are connected as root in your SSH session

    wget https://raw.githubusercontent.com/mrikirill/SynologyDDNSCloudflareMultidomain/master/install.sh -O install.sh && sudo bash install.sh
    

    Note: For SRM users, you must connect to your device as root. No other username will allow these commands to run.

  1. Update your DDNS settings:

    a. For DSM Users: Navigate to Control Panel > External Access > DDNS then add new DDNS

    b. For SRM users: Navigate to Network Centre > Internet > QuickConnect & DDNS > DDNS and press the Add button:

    Add/Update the DDNS settings screen as follows:

    • Service provider: Select Cloudflare

    • πŸ†•Hostname: this field is not used anymore, you can put any value here

    • Username: For a single domain: mydomain.com For multiple domains: subdomain.mydomain.com|vpn.mydomain.com πŸ†•(ensure each domain is separated: |)πŸ†•

      Note: there is 256 symbols limit on Hostname input

    • Password: Your created Cloudflare API Key

    image

    Finally, press the test connection button to confirm all information is correctly entered, before pressing Ok to save and confirm your details.

  2. Enjoy 🍺 and don't forget to deactivate SSH (step 1) if you don't need it.

Troubleshooting and known issues

CloudFlare API free domains limitation

CloudFlare API doesn't support domains with a .cf, .ga, .gq, .ml, or .tk TLD (top-level domain)

For more details read here: #28 and https://community.cloudflare.com/t/unable-to-update-ddns-using-api-for-some-tlds/167228/61

Response example:

{
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 1038,
      "message": "You cannot use this API for domains with a .cf, .ga, .gq, .ml, or .tk TLD (top-level domain). To configure the DNS settings for this domain, use the Cloudflare Dashboard."
    }
  ],
  "messages": []
}

Connection test failed or error returned

This will manifest as either 1020 error; or the update attempt not showing in your Cloudflare Audit logs.

That generally means you may not have entered something correctly in the DDNS screen for your domain(s).

Revisit Before you begin to ensure you have all the right information, then go back to Step 4 in How to install to make sure everything is correctly entered.

Handy hint: You can also check your Cloudflare Audit logs to see what - if anything - has made it there with your API key (More information: Understanding Cloudflare Audit Logs). Updates using the API will appear in the Audit logs as a Rec Set action.

Cloudflare no longer listed as a DDNS provider after DSM or SRM updates

After system updates to either Synology DSM or SRM, you may find that:

  • /usr/syno/bin/ddns/cloudflare.php has been deleted;
  • /etc.defaults/ddns_provider.conf was reset to its default settings (settings for Cloudflare no longer included); and
  • The DDNS settings in your DDNS panel constantly show Cloudflare's status as loading.

If this occurs, simply repeat the How to install steps shown above.

Default Cloudflare ports

Source Identifying network ports compatible with Cloudflare's proxy

HTTP ports supported by Cloudflare HTTPS ports supported by Cloudflare
80 443
8080 2053
8880 2083
2052 2087
2082 2096
2086 8443
2095

Debug

You can run this script directly to see output logs

  • SSH into your Synology system

  • Run this command:

/usr/bin/php -d open_basedir=/usr/syno/bin/ddns -f /usr/syno/bin/ddns/cloudflare.php "" "domain1.com|vpn.domain2.com" "your-CloudFlare-token" "" ""
  • Check output logs

Credits

Table of contents generated with markdown-toc
DB Tech - creating API keys and using Cloudflare CNAME for single updates MKDoc - generate documentation

synologyddnscloudflaremultidomain's People

Contributors

iceman201 avatar mrikirill avatar rfuehrer avatar sdhawade avatar smoetje avatar twcau 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  avatar

synologyddnscloudflaremultidomain's Issues

Unknown error updating Cloudflare

Getting the following error once in a few days or sometimes multiple times a day. :
System failed to register the external IP address XX.XXX.XXX.XXX to domain.name in DDNS server Cloudflare. The reported reason is [Unknown Error].
Any pointers to finding out the error code would be useful

IPv6 Support

Will this script have IPv6 support in the future?

error 521 web server is down

i updated dsm and reinstalled the script but im getting the above. ive checkd everything via clouflare and the ddns says the status is normal in green.

Wildcard DNS record

How can I add wildcard (*.domain.com) DNS record?
DSM hostname string does not accept asterisk operator *.

image

IPv6 Support

What about implement IPv6 support in script?

Regards.

Synology DMS DDNS list isn't updated

I updated the DDNS config file following the instructions, downloaded the "cloudfare.php" file to the correct place and even ran the debug command through SSH, but Cloudfare still wouldn't show up in my list. I tried changing the name of Google just to test it, but it didn't update either.

Character limit

Hi there,

Is there any way to increase the 128 character limit on domain names?

I host multiple sites, so would like to be able to include all.

Thanks!

Attempting to update IP fails with status: "Synology Technical Support.">Failed."

After updating to DSM 7.1.1-42962 Update 5, and going through the reinstallation process for cloudflare.php etc, attempting to update the DDNS IP address now throws an error that I've never seen before: Synology Technical Support.">Failed.

I'm assuming something has changed with Update 5. Running the debug command throws an invalid ip-address error, and Cloudflare is not contacted according to the audit logs.

Please let me know what other things I can provide to help fix this new issue!

SCR-20230418-hsj

Run by command line / shell

Hi.

I realized that from time to time that the update / process hangs. I have two domain lists updating on a regular basis. If one of them times out or has another issue, it just stops for all ddns entries, including Synology.me.

Is there a way to initiate the update via shell using the existing values? I would just add two tasks to the task planer executing the script if possible

Avoid 128 chars limitation

I'm facing with chars limitations of 128 symbols... any way to avoid it? I can only add one DDNS for a single provider.

I have lots of domains to update 😭

At the moment I edited directly the cloudflare.php file to hard encode the long string. Just as fast fix.

Unknown error while update IP adress

I have set up the lastest version of SynologyDDNSCloudflareMultidomain on my Synology, but when i configure the DDNS, the DSM reports unknow error.

I have tired the debug command, and it gives the following error:

Catchable fatal error: Argument 2 passed to updateCFDDNS::setRecord() must be an instance of string, null given, called in /usr/syno/bin/ddns/cloudflare.php on line 85 and defined in /usr/syno/bin/ddns/cloudflare.php on line 226

SSL certificate is not valid

Hey I got everything up and running and can also access the website under the domain. I have now also added an SSL certificate in Synology DSM. The SSL certificate authorizes my domain and all subdomains. However, when I try to access the page from a subdomain, it is considered as not secure. The error message "Not Valid" appears. Do you know what could be the reason?

I activated the "Strict" SSL mode in Cloudflare and turned off the proxy for the DNS entry.

Thank you for your help.

Invalid Hostname Format

mrikirill,

I've installed the script and created an api token on cloudflare, all subdomains are created on cloudflare. When I try to add the ddns provider on my synology, I can add 9 suddomains on the add ddns page but when I add another subdomain it says I have an invalid hostname. Is there a limit of subdomains?

FYI CloudFlare API free domain limitation

Not exactly an issue but I wanted to pass this along for any poor soul who spent countless hours trying to get this to work only to find out there is a CloudFlare API limitation with free domains.

I was testing this out with a free .ml domain to no avail. I tried curling the API myself only to find this response.

{
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 1038,
      "message": "You cannot use this API for domains with a .cf, .ga, .gq, .ml, or .tk TLD (top-level domain). To configure the DNS settings for this domain, use the Cloudflare Dashboard."
    }
  ],
  "messages": []
}

Service provider not updating with new Cloudflare value

When finised editing the ddns_provider.conf file I confirm the entrie has saved.

I then check the Service provider dropdown and its not showing.
Rebooted the device, confirmed the new Cloudeflare is still in the conf file and its still not showing.

Unable to access my NAS without a VPN or proxy

I followed the instructions to set this up. I was unable to access my NAS using local wifi. But when I turned on a VPN app or use 4G on my phone, it's accessible. This was strange. Can anyone help me, please?

Project has no license

Hi @mrikirill ,

I noticed that the project does not include a license statement, so legally it is not actually open source. Is this intentional or would you rather have provided a free license such as MIT?

For this, the following notes from Github (https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/licensing-a-repository#what-happens-if-i-dont-choose-a-license):

You're under no obligation to choose a license. It's your right not to include one with your code or project, but please be aware of the implications. Generally speaking, the absence of a license means that the default copyright laws apply. This means that you retain all rights to your source code and that nobody else may reproduce, distribute, or create derivative works from your work. This might not be what you intend.

Even if this is what you intend, if you publish your source code in a public repository on GitHub, you have accepted the Terms of Service which do allow other GitHub users some rights. Specifically, you allow others to view and fork your repository.

if you want to share your work with others, we strongly encourage you to include an open source license.

Are you okay with me bringing in a PR with MIT?

Does not update DNS records on Cloudflare

I have domain .ML
It seems, that something is wrond, because Update Status in DDNS settings of Synology is Normal , but this status shows also if I try to put wrong credentials.

Do you know, where could be the issue?

Unable to update wildcard domain

I use '' in my cloudflare DNS to allow access to any ABC.mydomain.com instead of having to define each ABC name in the DNS.
Synology doesnt seem to accept the character '
' in the hostname field when configuring the connection. Is there a way around this?

Thanks!

Suggestion for an automatic installer in Python

Hello,

I came across someone who made a nice automatic installer, very easy to use, made in Python. A very simple cron job is set up and it runs the script at every boot-up. It thus makes sure it is always working, even after a DSM update (theoretically).

The original script is there: https://github.com/namukcom/SynologyCloudFlareDDNS/blob/master/setddns.py
I made a variant of it there: https://github.com/aleclerc7/SynologyCloudflareDDNS/blob/master/CloudflareSynologyDDNSProvider.py

Maybe adding such a script could make the life easier for many. One can just make a fork and make the necessary path change if he wants to be in control of what is downloaded to his Synology DSM. Then, it just works, even after an upgrade of DSM.

Kind regards.

How can i use 2 diffrents domaine ?

Hi,

Can i use the same api of my domaine 1 and add the second domaine to the hosts on nas ?

Is that possible ? or should i create 2 differents api

Than you

How to edit other DNS record

Hi, i would like to update all my DNS records... and not only the default hostaname.

How to update also FTP, SSH, mail, www etc...?

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.