Package: cloudflareddns
cloudflareddnsA tiny command line utility for implementing DDNS with Cloudflare.Supports virtually any server that is capable of running PythonSynology DiskStations supportedQuick to install usingyum/dnforpipSynopsisUpdate DNS A record forfoo.example.comto1.2.3.4cloudflareddns--hostnamefoo.example.com--ip1.2.3.4Likewise, for an AAAA record:cloudflareddns--hostnamefoo.example.com--ip2001:0db8:85a3:0000:0000:8a2e:0370:7334Get all options by simply runningcloudflareddns -h:usage: cloudflareddns [-h] [--email EMAIL] [--key KEY] [--hostname HOSTNAME]
                      [--ip IP] [--ttl TTL] [--verbose] [--version]

Update DDNS in Cloudflare.

optional arguments:
  -h, --help           show this help message and exit
  --email EMAIL        Cloudflare account email (omit if using API tokens)
  --key KEY            Cloudflare API key or token
  --hostname HOSTNAME  Hostname to set IP for
  --ip IP              The IP address
  --ttl TTL            TTL in seconds
  --verbose
  --version            show program's version number and exitWhen invoked without any options,cloudflareddnswill try to point the
FQDN (aka<hostname>.<domain-name>of the machine it runs on to its public IP address (auto-detected).Install and use with Synology DiskStationsYou can configure a Synology DiskStation with CloudFlare DDNS.It's worth noting that if your Synology DSM is recent enough, you can simply use Synology's own DDNS service, then create aCNAMErecord at your domain that points to it. The downside to this solution, however, is extra DNS lookup required to resolve domain to IP.Alternative solution is to usecloudflarednswhich ships with the necessary CLI interface for Synology compatibility:cloudflareddns-syno.Step 1. Access Synology via SSHLogin to your DSMGo to Control Panel > Terminal & SNMP > Enable SSH serviceUse your client or commandline to access Synology. If you don't have any, I recommend you try out Putty for Windows.Use your Synology admin account to connect.Step 2. InstallcloudflareddnsIf you're not a lazy man, checkoutinstructions on installing using virtualenvfor this step.
For quick setup instead:curl https://bootstrap.pypa.io/get-pip.py | python
pip install cloudflareddnsRun the following command to add new DDNS provider:cat >> /etc/ddns_provider.conf << 'EOF'
[USER_Cloudflare]
        modulepath=/bin/cloudflareddns-syno
        queryurl=https://www.cloudflare.com/
EOFStep 3. Get Cloudflare parametersIt is recommended to use a Cloudflare APItoken.
Check thewiki pagefor instructions on how to get an API token with the most secure permissions.Alternatively, you can get Cloudflare global API key in your account settings.Step 4. Setup DDNSLogin to your DSMGo to Control Panel > External Access > DDNS > AddSelect Cloudflare as service providerEnter your domain as hostnameIf using token authentication: enterxin the Username/Email, and API token as Password/Key.
The requirement to putxis due to Synology GUI's constraints not allowing for an empty fieldIf using global API key: enter your Cloudflare account as Username/Email, and API key as Password/KeyInstallation for CentOS/RHEL 7, 8sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum install cloudflareddnsInstallation for other systemsInstalling withpipis easiest:pip install cloudflareddnsUsage in Python scriptsfromcloudflareddnsimportcloudflareddnshostname='foo.example.com'ip='1.2.3.4'ifcloudflareddns.updateRecord(hostname,ip):print('Record is OK')...Requires using environment variables (see tips below).Specifying Cloudflare credentialsIn non-Synology systems, you can store Cloudflare credentials in either environment
variables or a configuration file.Via configuration fileCreate~/.cloudflare/cloudflare.cfgand put:[CloudFlare]email=user@example.com# Do not set if using an API Tokentoken=xxxxxxxxxxxxxxxxxxxxxxxxxxxVia environment variablesYou can put your Cloudflare credentials into the~/.bashrcfile:exportCF_API_EMAIL="user@example.com"# Do not set if using an API TokenexportCF_API_KEY="xxxxxx"Don't forget tosource ~/.bashrcif you have just put credentials in there.
Thecloudflareddnswill pick those up, so no need to pass--emailor--keyevery time.