Code Monkey home page Code Monkey logo

synologycloudflareddns's Introduction

Synology Cloudflare DDNS Script ๐Ÿ“œ

The is a script to be used to add Cloudflare as a DDNS to Synology NAS. The script used an updated API, Cloudflare API v4.

How to use

Access Synology via SSH

  1. Login to your DSM
  2. Go to Control Panel > Terminal & SNMP > Enable SSH service
  3. Use your client to access Synology via SSH.
  4. Use your Synology admin account to connect.

Run commands in Synology

  1. Download cloudflareddns.sh from this repository to /sbin/cloudflareddns.sh
wget https://raw.githubusercontent.com/joshuaavalon/SynologyCloudflareDDNS/master/cloudflareddns.sh -O /sbin/cloudflareddns.sh

It is not a must, you can put I whatever you want. If you put the script in other name or path, make sure you use the right path.

  1. Give others execute permission
chmod +x /sbin/cloudflareddns.sh
  1. Add cloudflareddns.sh to Synology
cat >> /etc.defaults/ddns_provider.conf << 'EOF'
[Cloudflare]
        modulepath=/sbin/cloudflareddns.sh
        queryurl=https://www.cloudflare.com
        website=https://www.cloudflare.com
E*.

queryurl does not matter because we are going to use our script but it is needed.

Get Cloudflare parameters

  1. Go to your domain overview page and copy your zone ID.
  2. Go to your profile > API Tokens > Create Token. It should have the permissions of Zone > DNS > Edit. Copy the api token.

Setup DDNS

  1. Login to your DSM
  2. Go to Control Panel > External Access > DDNS > Add
  3. Enter the following:
    • Service provider: Cloudflare
    • Hostname: www.example.com
    • Username/Email: <Zone ID>
    • Password Key: <API Token>

synologycloudflareddns's People

Contributors

dee76 avatar hedrauta avatar joshuaavalon avatar silverwzw 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  avatar  avatar  avatar  avatar

synologycloudflareddns's Issues

[Bug] <a little bug>

line 17 ip6fetch=$(ip -6 addr show eth0 | grep -oP "$ipv6Regex")
Modify to ip6fetch=$(ip -6 addr show ovs_eth0 | grep -oP "$ipv6Regex")

IPv6

Hello,

how I get this script work with IPv6?
When I change "A" to "AAAA" in the config file, it don't works.
After finishing the configuration the window looks like this when I open it again. It don't shows my IPv6 address. During the first configuration it shows my IPv6 address.

Bildschirmfoto 2019-04-19 um 01 39 57

badauth

i run this script manually, return badauth.
whether this script can run in DMS7.0+ ?
Or the clouflare auth api has changed?

[Feature] IPv6 Compatibility

Is your feature request related to a problem? Please describe.
Since my NAS has a publicly routable IPv6 address but shares an IPv4 address with everything else on my network, I'd like to have this script also create a AAAA record.

Describe the solution you'd like
I just want this script to also support IPv6, if possible.

Describe alternatives you've considered
Right now, I'm manually creating and updating my AAAA record but, that's not really a good long term solution.

EDIT: I just read through the closed issues and realized that this is an error on the DSM side. I'll close this now.

[Bug] A small problem in commonds for Synology

Describe the bug
In the commond of download cloudflareddns.sh
wget https://raw.githubusercontent.com/joshuaavalon/SynologyCloudflareDDNS/master/cloudflareddns.sh -O /sbin/cloudflaredns.sh

The file has been renamed as cloudflaredns.sh (not cloudflareddns.sh)

Then if the user just copy the code in step 3:
cat >> /etc.defaults/ddns_provider.conf << 'EOF'
[Cloudflare]
modulepath=/sbin/cloudflareddns.sh

In this case, the Synology DDNS setting cannot find correct file to run the commonds.

Daily DDNS update fails but manual update works

Since last week, I have a Synology NAS reports DDNS service failed to register IP address everyday.
The notification shows Unknown Error. But the DSM DDNS webui shows Failed to connect server.
The /var/log/cloudflareddns.log shows
cloudflaredns.sh (7): Updating with x.x.x.x...
cloudflaredns.sh (7): RESPONSE==
cloudflaredns.sh (7): Status:

But when I click 'Update' button, the DDNS entry returns 'Normal' after couple seconds loading. And shows the next update is the following day.
In this case, the /var/log/cloudflareddns.log shows
cloudflaredns.sh (7): Updating with x.x.x.x...
cloudflaredns.sh (7): Status: good

I have two DDNS entries, one is Cloudflare DDNS using this script, the other one is Synology DDNS without issue. The Synology NAS is in China mainland. The Internet IP address has not been changed since the issue observed. I have reason to suspect that it is really network related issue. The ISP might be interfering the communication to Cloudflare. However I do not understand why it only impacts the auto daily DDNS update. Is there any difference between the schedule update and manual update. Do they have the different timeout value if the Internet quality is not ideal? Or do they use different reporting URLs which might be blocked?

Any clue helps the investigation will be appreciated. Thanks for this wonderful script.

[Bug] Various synology web services constantly refreshing and never fully loading in browser

Describe the bug
So I'm a bit mystified by this. If I visit my NAS using its IP address everything loads and works fine. But if I use the DDNS sub-domain address I have set up (and which is pointing to the correct IP in Cloudflare thanks to this DDNS script), then I find that the page starts loading and then gets stuck in an eternal loop trying to load and restarting and trying to load and restarting. At first it seemed to only happen in Firefox, but then also happened in Chrome. I can't really work out what's causing the issue. As it doesn't happen when using the IP address, I wondered whether it could have something to do with this script and Cloudflare, or is it more likely a bug that I need to report to synology? I thought I'd check here first though.

Cheers!
Alex

[Bug] Bad authentication error

Describe the bug
bad authentication error

To Reproduce
Steps to reproduce the behavior:

After last Synology update 6.2.4 I had to reinstall your script.
I respect all your steps but I get Authentication failed.

I edit your script with my credentials and my IP and when I run it in command line, I get "badauth"

Additional context
I used your script before with version 6.2.1-6.2.3 and I hadn't any problem

[Bug] DNS posting failure

Error in synology "can't assign IP x.x.x.x to host address [unknown error]"

I have NAS added to section tunels in zero trust with https://localhost as target.
When I'm trying to put credentials to DDNS window in my DSM "can't connect to server, check connection status" in status of connection.
I tried to generate token with and without additional Zones>Zones-Read.

when I tried curl from SSH:

curl -s -X POST "https://api.cloudflare.com/client/v4/zones/[ZONEID]/dns_records" -H "Authorization: Bearer {TOKEN]" -H "Content-Type:application/json" --data "{"type":"A","name":"[AA.DOMAIN.COM]","content":"[IPADDRESS]","proxied":true}"
i receive response:

{"result":null,"success":false,"errors":[{"code":81054,"message":"A CNAME record with that host already exists. For more details, refer to \u003chttps://developers.cloudflare.com/dns/manage-dns-records/troubleshooting/records-with-same-name/\u003e."}],"messages":[]}

I deleted DNS and then record was made. With A type instead of CNAME but still it's not working properly.

DSM version 5.2.

Wild Card Domain

How can the script be modified to take more than one response from the GET request to set up a new IP?
Currently it uses only result[0]. But what if I have two type A records, one "example.com" (result[0]) and a second wildcard "*" (result[1]).

[Feature] Possible IPv6-Support through built in shell-commands

Since I read alot of Issues about Synology is not transmitting the IPv6 to the script, I thought about fetching the IPv6 on my own....

I tried a lot.... but it looks like, that i "may" broke the script....

My Idea was fetching the Inet6-adresses from "ip -6 addr show eth0" ( which do contain 2 kinds of adresses ) filter the first adress, and copy all relevant commands.
Well.... it "should" work...... but it doesn't...

Maybe as a feature, to try fetching the IPv6 and sent it to Cloudflare..... I'm going to revert my changes for today.... I'm done -.-

What I tried so far:

removed

Provider disappears

After I add 1 ddns record, the provider disappears from the add new record.
How do I fix that?

[Feature] IPv6 Support with "dynamic switch"

This: https://github.com/Hedrauta/SynologyCloudflareDDNS
actually is a good fork from @Hedrauta but there is still a problem I think:

  1. IPv6 is not provided from Synology (at least for me)
  2. if both (IPv4 & IPv6) are set and just one of them changes and the other will be removed this should be projected to Cloudflares DNS and remove the (for example) IPv4

I think this example from @Hedrauta should be paired with this one: https://github.com/lifehome/systemd-cfddns/blob/master/src/cfupdater-dualstack

which would make this a very stable and good solution. Also for DS-Lite users it would be awesome to be able to set the script in "IPv6Only" Mode as the IPv4 on DS-Lite users are shared among more users and thats why most things will not work on IPv4 for DS-Lite Users then.

Also I think IPs should not even be obtained from Synologys-DDNS service, but resolved itself with:

  1. curl -4 https://icanhazip.com/ OR curl -s https://ipv4.icanhazip.com/
  2. curl -6 https://icanhazip.com/ OR curl -s https://ipv6.icanhazip.com/

and then valideted with your validation and then be:

  1. created (if missing)
  2. updated (if existing but changed)
  3. deleted (if existing on Cloudflare but not on device anymore)

Just wanted to drop these infos here and hope that @Hedrauta may sees them and implements them in his script, as he did not allow us to create issues.

Broken?

Hi,

i followed your installation steps 2 times and i always get:

authentication failed

I checked zone DNS and token 3 Times they are working. Also my hostname exists.

Any help would be good.

Thank you

Record ID?

After running the curl command to obtain the Record ID I get the following output. Where can I find the Record ID in it?

{"result":{"id":"xxx",
"name":"abc.xyz",
"status":"active",
"paused":false,
"type":"full",
"development_mode":0,
"name_servers":["a.ns.cloudflare.com","b.ns.cloudflare.com"],
"original_name_servers":["ns2.hosting.com","ns1.hosting.com"],
"original_registrar":null,
"original_dnshost":null,
"modified_on":"2017-04-27T18:16:49.798322Z",
"created_on":"2017-04-12T19:37:00.509568Z",
"meta":{"step":4,
"wildcard_proxiable":false,
"custom_certificate_quota":0,
"page_rule_quota":3,
"phishing_detected":false,
"multiple_railguns_allowed":false},
"owner":{"type":"user",
"id":"XXX",
"email":"[email protected]"},
"permissions":["#analytics:read",
"#billing:edit",
"#billing:read",
"#cache_purge:edit",
"#dns_records:edit",
"#dns_records:read",
"#lb:edit",
"#lb:read",
"#logs:read",
"#organization:edit",
"#organization:read",
"#ssl:edit",
"#ssl:read",
"#waf:edit",
"#waf:read",
"#zone:edit",
"#zone:read",
"#zone_settings:edit",
"#zone_settings:read"],
"plan":{"id":"0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"name":"Free Website",
"price":0,
"currency":"USD",
"frequency":"",
"is_subscribed":true,
"can_subscribe":false,
"legacy_id":"free",
"legacy_discount":false,
"externally_managed":false}},
"success":true,
"errors":[],
"messages":[]}

In addition which variables do I input into cloudflareddns.sh? Is it the following?

# CloudFlare Config
__RECID__=""
__ZONE_ID__=""

IPv6 not updated

ipv4 works fine, but ipv6 address is not updated...DSM doesn't even provide the ipv6 address to the script. Any idea?

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.