Skip to content
/ PyDDNS Public

Python based Dynamic Domain Name System updater for Dreamhost and Cloudflare

License

Notifications You must be signed in to change notification settings

TORQDL/PyDDNS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

- THIS PROJECT IS STILL UNDER HEAVY DEVELOPMENT AND IS NOT READY FOR USE -

 

PyDDNS

Python DDNS for DreamHost and Cloudflare


PyDDNS is a python based Dynamic Domain Name System updater for DreamHost and Cloudflare.


Issue tracking available on GitKraken Boards


Getting Started

Requirements

Python 3 with urllib. Should be installed by default, if not use your package manager.

Installation

Automated Installation

Run the following command in your terminal:

curl -s -S -L https://raw.githubusercontent.com/TORQDL/PyDDNS/master/scripts/install.sh | sh -s -- -v

The script also accepts some options:

  • -c <channel> to use specified channel.
  • -r to reinstall AdGuard Home;
  • -u to uninstall AdGuard Home;
  • -v for verbose output;

Note that options -r and -u are mutually exclusive.

Manual installation

Please read these instructions.

Usage

Configuration

Configuration is done through JSON in a configuration file. DreamHost and Cloudflare each use different configuration parameters for authentication, but use the same information for updating your DNS records.

PyDDNS supports updating both IPv4 and IPv6 addresses in DNS using A and AAAA records resspectively. It can update the record using either your public IP address (most common) or the local IP address (less common).

JSON Configuration Parameters

DreamHost Specific Description
api_key Your DreamHost API Key

Example: ABCD1234EFGH5678
Cloudflare Specific Description
api_token Your Clourflare API Token with Zone.DNS permissions

Example: 1234567893feefc5f0q5000bfo0c38d90bbeb
api_key Your Cloudflare Global API Key

Example: 3feefc5f0q5000bfo0c38d90bbeb123456789
account_email Your Cloudflare login email address

Example: yourname@example.com
zone_id The Zone ID of the site whose DNS you wish to update

Example: 5000bfo0c38d90bbeb1234567893feefc5f0q
proxied Whether or not the domain or subdomain should be proxied through Cloudflare. For more information, see Cloudflare's Help Center

Boolean: true or false
Parameters for Both Description
domain_or_subdomain The domain or subdomain

Example: example.com or sub.example.com
ipv4 Whether the A record should be updated with an IPv4 address.

Boolean: true or false
ipv6 Whether the AAAA record should be updated with an IPv6 address.

Boolean: true or false
local_ip Whether the local IP address should be used instead of the public IP address. If set to true, the local IP address will be used.

Boolean: true or false

DreamHost Logo DreamHost

What you will need:

  • DreamHost API Key: you will need your DreamHost API key, configured for all DNS functions.

You can get your API key from the DreamHost Web Panel. For more information on this, please see the DreamHost API Overview.

When configuring your API key, please give it access to All dns functions:

  • All dns functions
  • dns-add_record
  • dns-list_records
  • dns-remove_record

It should look similar to this in your list of existing API keys after it is created:

API KEY CREATED COMMENT FUNCTION ACCESS ACTIONS
ABCD1234EFGH5678 2021-09-14 09:41:00 PyDDNS Key dns-* ⊗ Destroy

Once you have your API key, you can fill in the dreamhost.json configuration file as follows:

{
    "dns": [
        {
            "provider": "dreamhost",
            "authentication": {
                "api_key": "ABCD1234EFGH5678"
            },
            "records": {
                "example.com": {
                    "ipv4": true,
                    "ipv6": true,
                    "local_ip": false
                },
                "sub.example.com": {
                    "ipv4": true,
                    "ipv6": true,
                    "local_ip": false
                }
            }
        }
    ]
}

Cloudflare Logo Cloudflare

TODO:

  • instructions for finding cloudflare API key
  • instructions for finding Cloudflare zone id
  • instructions for creating API token for DNS

Cloudflare Dashboard

curl -X GET "https://api.cloudflare.com/client/v4/user/tokens/verify" \
     -H "Authorization: Bearer 1234567893feefc5f0q5000bfo0c38d90bbeb" \
     -H "Content-Type:application/json"
{
    "dns": [
        {
            "provider": "cloudflare",
            "authentication": {
                "api_token": "1234567893feefc5f0q5000bfo0c38d90bbeb",
                "api_key": "3feefc5f0q5000bfo0c38d90bbeb123456789",
                "account_email": "yourname@example.com"
            },
            "zones": {
                "5000bfo0c38d90bbeb1234567893feefc5f0q": {
                    "records": {
                        "example.com": {
                            "ipv4": true,
                            "ipv6": true,
                            "proxied": true,
                            "local_ip": false
                        },
                        "sub.example.com": {
                            "ipv4": true,
                            "ipv6": true,
                            "proxied": true,
                            "local_ip": false
                        }
                    }
                }
            }
        }
    ]
}

How to Run

TODO:

  • running based on automated install script
  • running based on git clone

Schedule

TODO:

  • scheduling PyDDNS to run regularly
  • scheduling PyDDNS to check for updates via automated script
  • scheduling PyDDNS to check for updates via git

Acknowledgments

PyDDNS was inspired by and uses code from:

Issue labels for the repository are managed using git-labelmaker by GitHub Logo Dave Lunny.

Issue tracking and automation are managed on GitKraken Boards

License

PyDDNS is licensed under the MIT License, a short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code. This is not legal advice. Learn more about repository licenses.

See the PyDDNS LICENSE

Privacy

PyDDNS does not collect any usage statistics. However, as it connects to and utilizes the DreamHost and/or Cloudflare APIs, certain information may be collected by DreamHost and/or Cloudflare per their respective privacy policies and terms of use. Please visit DreamHost and Cloudflare for more information.

Donation

TODO:

  • add links for donations

- text in red
+ text in green
! text in orange
# text in gray
@@ text in purple (and bold)@@