Giter Club home page Giter Club logo

ddns-updater's Introduction

Lightweight universal DDNS Updater with Docker and web UI

Light container updating DNS A records periodically for Cloudflare, DDNSS.de, DNSPod, Dreamhost, DuckDNS, GoDaddy, Google, Infomaniak, Namecheap and NoIP

DDNS Updater by Quentin McGaw

Build status Docker Pulls Docker Stars Image size Image version

Join Slack channel GitHub last commit GitHub commit activity GitHub issues

Features

  • Updates periodically A records for different DNS providers: Cloudflare, DDNSS.de, DNSPod, Dreamhost, DuckDNS, GoDaddy, Google, Infomaniak, Namecheap and NoIP (create an issue for more)
  • Web User interface

Web UI

  • 14MB Docker image based on a Go static binary in a Scratch Docker image with ca-certificates and timezone data
  • Persistence with a JSON file updates.json to store old IP addresses with change times for each record
  • Docker healthcheck verifying the DNS resolution of your domains
  • Highly configurable
  • Sends notifications to your Android phone, see the Gotify section (it's free, open source and self hosted ๐Ÿ†’)
  • Compatible with amd64, 386, arm64, arm32v7 (Raspberry Pis) CPU architectures.

Setup

The program reads the configuration from a JSON configuration file.

  1. First, create a JSON configuration starting from, for example:

    {
        "settings": [
            {
                "provider": "namecheap",
                "domain": "example.com",
                "host": "@",
                "password": "e5322165c1d74692bfa6d807100c0310"
            },
            {
                "provider": "duckdns",
                "domain": "example.duckdns.org",
                "token": "00000000-0000-0000-0000-000000000000"
            },
            {
                "provider": "godaddy",
                "domain": "example.org",
                "host": "subdomain",
                "key": "aaaaaaaaaaaaaaaa",
                "secret": "aaaaaaaaaaaaaaaa"
            }
        ]
    }
  2. You can find more information in the configuration section to customize it.

  3. You can either use a bind mounted file or put all your JSON in a single line with the CONFIG environment variable, see the two subsections below for each

Using the CONFIG variable

  1. Remove all 'new lines' in order to put your entire JSON in a single line (i.e. {"settings": [{"provider": "namecheap", ...}]})

  2. Set the CONFIG environment variable to your single line configuration

  3. Use the following command:

    docker run -d -p 8000:8000/tcp -e CONFIG='{"settings": [{"provider": "namecheap", ...}]}' qmcgaw/ddns-updater

Note that this CONFIG environment variable takes precedence over the config.json file if it is set.

Using a file

  1. Create a directory of your choice, say data with a file named config.json inside:

    mkdir data
    touch data/config.json
    # Owned by user ID of Docker container (1000)
    chown -R 1000 data
    # all access (for creating json database file data/updates.json)
    chmod 700 data
    # read access only
    chmod 400 data/config.json

    (You could change the user ID, for example with 1001, by running the container with --user=1001)

  2. Place your JSON configuration in data/config.json

  3. Use the following command:

    docker run -d -p 8000:8000/tcp -v "$(pwd)"/data:/updater/data qmcgaw/ddns-updater

Next steps

You can also use docker-compose.yml with:

docker-compose up -d

You can update the image with docker pull qmcgaw/ddns-updater. Other Docker image tags are available.

Configuration

Start by having the following content in config.json, or in your CONFIG environment variable:

{
    "settings": [
        {
            "provider": "",
        },
        {
            "provider": "",
        }
    ]
}

The following parameters are to be added:

For all record update configuration, you have to specify the DNS provider with "provider" which can be "cloudflare", "ddnss", "dnspod", "dreamhost", "duckdns", "godaddy", "google", "infomaniak", "namecheap" or "noip". You can optionnally add the parameters:

  • "no_dns_lookup" can be true or false and allows, if true, to prevent the periodic Docker healthcheck from running a DNS lookup on your domain.
  • "provider_ip" can be true or false. It is only available for the providers ddnss, duckdns, infomaniak, namecheap and noip. It allows to let your DNS provider to determine your IPv4 address (and/or IPv6 address) automatically when you send an update request, without sending the new IP address detected by the program in the request.

For each DNS provider exist some specific parameters you need to add, as described below:

Namecheap:

  • "domain"
  • "host" is your host and can be a subdomain, "@" or "*" generally
  • "password"

Cloudflare:

  • "zone_identifier" is the Zone ID of your site
  • "domain"
  • "host" is your host and can be a subdomain, "@" or "*" generally
  • "ttl" integer value for record TTL in seconds (specify 1 for automatic)
  • One of the following:
    • Email "email" and Global API Key "key"
    • User service key "user_service_key"
    • API Token "token", configured with DNS edit permissions for your DNS name's zone.
  • Optionally, "proxied" can be true or false to use the proxy services of Cloudflare
  • "ip_version" can be ipv4 (A records) or ipv6 (AAAA records), defaults to ipv4 or ipv6

GoDaddy:

  • "domain"
  • "host" is your host and can be a subdomain, "@" or "*" generally
  • "key"
  • "secret"
  • "ip_version" can be ipv4 (A records) or ipv6 (AAAA records), defaults to ipv4 or ipv6

DuckDNS:

  • "domain" is your fqdn, for example subdomain.duckdns.org
  • "token"
  • "ip_version" can be ipv4 (A records) or ipv6 (AAAA records), defaults to ipv4 or ipv6

Dreamhost:

  • "domain"
  • "key"
  • "ip_version" can be ipv4 (A records) or ipv6 (AAAA records), defaults to ipv4 or ipv6

NoIP:

  • "domain"
  • "host" is your host and can be a subdomain or "@"
  • "username"
  • "password"
  • "ip_version" can be ipv4 (A records) or ipv6 (AAAA records), defaults to ipv4 or ipv6

DNSPOD:

  • "domain"
  • "host" is your host and can be a subdomain or "@"
  • "token"
  • "ip_version" can be ipv4 (A records) or ipv6 (AAAA records), defaults to ipv4 or ipv6

Infomaniak:

  • "domain"
  • "host" is your host and can be a subdomain or "@"
  • "user"
  • "password"
  • "ip_version" can be ipv4 (A records) or ipv6 (AAAA records), defaults to ipv4 or ipv6

DDNSS.de:

  • "domain"
  • "host" is your host and can be a subdomain or "@"
  • "user"
  • "password"
  • "ip_version" can be ipv4 (A records) or ipv6 (AAAA records), defaults to ipv4 or ipv6

Google:

  • "domain"
  • "host" is your host and can be a subdomain or "@" or "*"
  • "username"
  • "password"
  • "ip_version" can be ipv4 (A records) or ipv6 (AAAA records), defaults to ipv4 or ipv6

Additional notes

  • You can specify multiple hosts for the same domain using a comma separated list. For example with "host": "@,subdomain1,subdomain2",.

Environment variables

Environment variable Default Description
CONFIG One line JSON object containing the entire config (takes precendence over config.json file) if specified
PERIOD 5m Default period of IP address check, following this format
IP_METHOD cycle Method to obtain the public IP address (ipv4 or ipv6). See the IP Methods section
IPV4_METHOD cycle Method to obtain the public IPv4 address only. See the IP Methods section
IPV6_METHOD cycle Method to obtain the public IPv6 address only. See the IP Methods section
HTTP_TIMEOUT 10s Timeout for all HTTP requests
LISTENING_PORT 8000 Internal TCP listening port for the web UI
ROOT_URL / URL path to append to all paths to the webUI (i.e. /ddns for accessing https://example.com/ddns through a proxy)
BACKUP_PERIOD 0 Set to a period (i.e. 72h15m) to enable zip backups of data/config.json and data/updates.json in a zip file
BACKUP_DIRECTORY /updater/data Directory to write backup zip files to if BACKUP_PERIOD is not 0.
LOG_ENCODING console Format of logging, json or console
LOG_LEVEL info Level of logging, info, warning or error
NODE_ID -1 Node ID (for distributed systems), can be any integer
GOTIFY_URL (optional) HTTP(s) URL to your Gotify server
GOTIFY_TOKEN (optional) Token to access your Gotify server

IP methods

By default, all ip methods are cycled through between all ip methods available for the specified ip version, if any. This allows you not to be blocked for making too many requests. You can otherwise pick one of the following.

You can also specify an HTTPS URL to obtain your public IP address (i.e. -e IPV6_METHOD=https://ipinfo.io/ip)

Host firewall

If you have a host firewall in place, this container needs the following ports:

  • TCP 443 outbound for outbound HTTPS
  • TCP 80 outbound if you use a local unsecured HTTP connection to your Gotify server
  • UDP 53 outbound for outbound DNS resolution
  • TCP 8000 inbound (or other) for the WebUI

Domain set up

Instructions to setup your domain for this program are available for DuckDNS, Cloudflare, GoDaddy and Namecheap on the Github Wiki.

Gotify

Gotify

Gotify is a simple server for sending and receiving messages, and it is free, private and open source

  • It has an Android app to receive notifications
  • The app does not drain your battery ๐Ÿ‘
  • The notification server is self hosted, see how to set it up with Docker
  • The notifications only go through your own server (ideally through HTTPS though)

To set it up with DDNS updater:

  1. Go to the Web GUI of Gotify
  2. Login with the admin credentials
  3. Create an app and copy the generated token to the environment variable GOTIFYTOKEN (for this container)
  4. Set the GOTIFYURL variable to the URL of your Gotify server address (i.e. http://127.0.0.1:8080 or https://bla.com/gotify)

Testing

  • The automated healthcheck verifies all your records are up to date using DNS lookups

  • You can also manually check, by:

    1. Going to your DNS management webpage
    2. Setting your record to 127.0.0.1
    3. Run the container
    4. Refresh the DNS management webpage and verify the update happened

    Better testing instructions are written in the Wiki for GoDaddy

Development and contributing

License

This repository is under an MIT license

Used in external projects

Support

Sponsor me on Github or donate to paypal.me/qmcgaw

https://github.com/sponsors/qdm12 https://www.paypal.me/qmcgaw

Many thanks to J. Famiglietti for supporting me financially ๐Ÿฅ‡๐Ÿ‘

ddns-updater's People

Watchers

 avatar

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.