|
1 | | -Synology DDNS Cloudflare with multidomains and subdomains |
2 | | -======================== |
3 | 1 |
|
4 | | -Update note |
5 | | ---------------- |
6 | | -I've mentioned that after Synology DSM update, the file __/usr/syno/bin/ddns/cloudflare.php__ has been deleted and __/etc.defaults/ddns_provider.conf__ reset to default settings. |
| 2 | +# Synology Dynamic DNS with Cloudflare for both multidomains and subdomains |
7 | 3 |
|
8 | | -For that case you need just repeat all installations steps. |
| 4 | +## Table of contents |
9 | 5 |
|
10 | | -The list of default Cloudflare ports |
11 | | ---------------- |
| 6 | +* [What this script does](#what-this-script-does) |
| 7 | +* [Before you begin](#before-you-begin) |
| 8 | +* [How to install](#how-to-install) |
| 9 | +* [Troubleshooting and known issues](#troubleshooting-and-known-issues) |
| 10 | + + [Connection test failed or error returned](#connection-test-failed-or-error-returned) |
| 11 | + + [Cloudflare no longer listed as a DDNS provider after a DSM update](#cloudflare-no-longer-listed-as-a-ddns-provider-after-a-dsm-update) |
| 12 | +* [Default Cloudflare ports](#default-cloudflare-ports) |
12 | 13 |
|
13 | | -HTTP ports supported by Cloudflare: |
14 | 14 |
|
15 | | -80 |
16 | | -8080 |
17 | | -8880 |
18 | | -2052 |
19 | | -2082 |
20 | | -2086 |
21 | | -2095 |
| 15 | +## What this script does |
22 | 16 |
|
23 | | -HTTPS ports supported by Cloudflare: |
24 | | - |
25 | | -443 |
26 | | -2053 |
27 | | -2083 |
28 | | -2087 |
29 | | -2096 |
30 | | -8443 |
31 | | - |
32 | | -Description |
33 | | ---------------- |
34 | | -* A PHP script for Synology DSM (and potentially Synology SRM devices) which adds Cloudflare DDNS support in your DMS |
35 | | -* Supports multidomains, subdomains and also regional domains (example: dev.my.domain.com.au, domain.com.uk etc) |
| 17 | +* A PHP script for Synology DSM (and potentially Synology SRM devices) adding support for Cloudflare to Network Centre > Dynamic DNS (DDNS). |
| 18 | +* Supports single domains, multidomains, subdomains and regional domains, or any combination thereof (example: dev.my.domain.com.au, domain.com.uk etc) |
36 | 19 | * Easy instalation process |
37 | 20 | * Based on CloudFlare API v4 |
38 | 21 |
|
39 | | -Before start to use this script |
40 | | ---------------- |
41 | | -* Have a Cloudflare account with active domains |
42 | | -* Have A Records |
| 22 | +## Before you begin |
| 23 | + |
| 24 | +Before starting the installation process, make sure you have (and know) the following information, or have completed these steps: |
| 25 | + |
| 26 | + 1. *Cloudflare credentials* |
| 27 | + |
| 28 | + a. Know your Cloudflare account username (or [register for an account if you're new to Cloudflare](https://dash.cloudflare.com/sign-up)); and |
| 29 | + |
| 30 | + b. Have your [Global API key](https://dash.cloudflare.com/profile/api-tokens) (More info: [Global API keys](https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys)). |
| 31 | + |
| 32 | + 2. *DNS settings:* |
| 33 | + |
| 34 | + 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](https://support.cloudflare.com/hc/en-us/articles/360019093151-Managing-DNS-records-in-Cloudflare)). |
| 35 | + |
| 36 | + Your DNS records should appear (or already be setup as follows) in Cloudflare: |
| 37 | + |
| 38 | + (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) |
| 39 | + |
| 40 | +  |
43 | 41 |
|
44 | | -Example |
45 | | ---------------- |
46 | | - |
| 42 | +## How to install |
47 | 43 |
|
48 | | -Installation |
49 | | ----------------- |
50 | | -1. Activate SSH in DMS (__Control Panel -> Terminal & SNMP -> Enable SSH service__) |
51 | | - |
| 44 | +1. **Activate SSH on your supported device:** |
52 | 45 |
|
53 | | -2. Connect via SSH and execute command |
| 46 | + a. For DSM Users: |
| 47 | + |
| 48 | + Navigate to __Control Panel > Terminal & SNMP > Enable SSH service__ |
| 49 | + |
| 50 | + b. For SRM users: |
| 51 | + |
| 52 | + Navigate to __Control Panel > Services > System Services > Terminal > Enable SSH service__ |
| 53 | + |
| 54 | +  |
54 | 55 |
|
55 | | -* DSM Users |
| 56 | +2. **Connect via SSH:** Connect to your supported device via SSH and execute command |
| 57 | + |
| 58 | +* For DSM Users |
56 | 59 | ``` |
57 | 60 | wget https://raw.githubusercontent.com/mrikirill/SynologyDDNSCloudflareMultidomain/master/cloudflare.php -O /usr/syno/bin/ddns/cloudflare.php && sudo chmod 755 /usr/syno/bin/ddns/cloudflare.php |
58 | 61 | ``` |
59 | 62 |
|
60 | | -* SRM Users |
| 63 | +* For SRM Users |
61 | 64 | Note: Ensure you are connected as root in your SSH session |
62 | 65 | ``` |
63 | 66 | wget https://raw.githubusercontent.com/mrikirill/SynologyDDNSCloudflareMultidomain/master/cloudflare.php -O /usr/syno/bin/ddns/cloudflare.php && chmod 755 /usr/syno/bin/ddns/cloudflare.php |
64 | 67 | ``` |
65 | 68 |
|
66 | | -3. Add Cloudflare to the list of DDNS providers DMS file(Location : __/etc.defaults/ddns_provider.conf__) |
| 69 | + **Note:** For SRM users, you must connect to your device as root. No other username will allow these commands to run. |
| 70 | + |
| 71 | +3. **Update DDNS provider list:** Using your preferred/available command line editor, insert the text below to your DMS file (Location : __/etc.defaults/ddns_provider.conf__), to add DDNS support via Cloudflare: |
| 72 | + |
| 73 | + ``` |
| 74 | + [Cloudflare] |
| 75 | + modulepath=/usr/syno/bin/ddns/cloudflare.php |
| 76 | + queryurl=https://www.cloudflare.com/ |
| 77 | + ``` |
| 78 | + |
| 79 | + **Note:** For SRM users, break out this [Vim cheat sheet](https://coderwall.com/p/adv71w/basic-vim-commands-for-getting-started), as it's the only text editor available to you. |
| 80 | + |
| 81 | +4. **Update your DDNS settings:** |
| 82 | + |
| 83 | + a. *For DSM Users:* Navigate to __Control Panel > External Access > DDNS__ then add new DDNS |
| 84 | + |
| 85 | + b. *For SRM users:* Navigate to __Network Centre > Internet > QuickConnect & DDNS > DDNS__ and press the Add button: |
| 86 | + |
| 87 | + Add/Update the DDNS settings screen as follows: |
| 88 | + |
| 89 | + * Service provider: Select Cloudflare |
| 90 | + * Hostname: |
| 91 | + For a single domain: __mydomain.com__ |
| 92 | +For multiple domains: __subdomain.mydomain.com---vpn.mydomain.com__ |
| 93 | + (ensure each domain is seperated by three dashes: ---) |
| 94 | + * Username: The email address you use for logging in to Cloudflare. |
| 95 | + * Password: Your Cloudflare Global API Key |
| 96 | + |
| 97 | +  |
| 98 | + |
| 99 | + Finally, press the test connection button to confirm all information is correctly entered, before pressing Ok to save and confirm your details. |
| 100 | + |
| 101 | +5. Enjoy 🍺 and __don't forget to deactivate SSH (step 1) if you don't need it__. |
| 102 | + |
| 103 | +## Troubleshooting and known issues |
| 104 | + |
| 105 | +### Connection test failed or error returned |
| 106 | + |
| 107 | +This will manifest as either 1020 error; or the update attempt not showing in your Cloudflare Audit logs. |
| 108 | + |
| 109 | +That generally means you may not have entered something correctly in the DDNS screen for your domain(s). |
| 110 | + |
| 111 | +Revisit [Before you begin](#before-you-begin) to ensure you have all the right information, then go back to Step 4 in [How to install](#how-to-install) to make sure everything is correctly entered. |
| 112 | + |
| 113 | +**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](https://support.cloudflare.com/hc/en-us/articles/115002833612-Understanding-Cloudflare-Audit-Logs)). Updates using the API will appear in the Audit logs as a Rec Set action. |
| 114 | + |
| 115 | +### Cloudflare no longer listed as a DDNS provider after a DSM update |
| 116 | + |
| 117 | +After updates to Synology DSM, you may find the file __/usr/syno/bin/ddns/cloudflare.php__ has been deleted, and __/etc.defaults/ddns_provider.conf__ reset to default settings. |
67 | 118 |
|
68 | | -``` |
69 | | -[Cloudflare] |
70 | | - modulepath=/usr/syno/bin/ddns/cloudflare.php |
71 | | - queryurl=https://www.cloudflare.com/ |
72 | | -``` |
| 119 | +If this occurs, simply [repeat the How to install steps](#how-to-install) shown above. |
73 | 120 |
|
74 | | -5. Than go to DMS settingS __Control Panel -> External Access -> DDNS__ and add new DDNS: |
| 121 | +## Default Cloudflare ports |
| 122 | +Source [Identifying network ports compatible with Cloudflare's proxy](https://support.cloudflare.com/hc/en-us/articles/200169156-Identifying-network-ports-compatible-with-Cloudflare-s-proxy) |
75 | 123 |
|
76 | | -* Select Cloudflare as a service provider |
77 | | -* Set in __hostname__ field your list of domains divided by __---__ example: __mydoman.com---subdomain.mydomain.com---vpn.mydomain.com__ or simple: __mydomain.com__ |
78 | | -* Set your Cloudflare acoount email into __Username/Email__ field |
79 | | -* Set Cloudflare Global API Key into __Password/Key__ field (See: [https://dash.cloudflare.com/profile/api-tokens](https://dash.cloudflare.com/profile/api-tokens)) |
| 124 | +|HTTP ports supported by Cloudflare | HTTPS ports supported by Cloudflare | |
| 125 | +|--|--| |
| 126 | +| 80 | 443 | |
| 127 | +| 8080 | 2053 | |
| 128 | +| 8880 | 2083 | |
| 129 | +| 2052 | 2087 | |
| 130 | +| 2082 | 2096 | |
| 131 | +| 2086 | 8443 | |
| 132 | +| 2095 | | |
80 | 133 |
|
81 | | - |
| 134 | +## Credits |
82 | 135 |
|
83 | | -6. Enjoy 🍺 and __don't forget to deactivate SSH (step 1) if you don't need it__ |
| 136 | +<small><i><a href='http://ecotrust-canada.github.io/markdown-toc/'>Table of contents generated with markdown-toc</a></i></small> |
0 commit comments