Skip to content

HaschekSolutions/opendyndns

Repository files navigation

Open DynDNS

Open DynDNS

Apache License Hits

Selfhosted dyn DNS solution with a simple REST API

Features

  • Web UI to manage hosts and add notes to hosts
  • API manages dnsmasq configs and updates server
  • Update your hosts via simple REST API (eg via curl)
  • Autodetect IPs or supply via POST parameters
  • IPv4 and IPv6 supported
  • Can be configured to be a open resolver (eg so OpenDynDNS can be your LANs DNS with dynamic hostname updates)
  • 100% File based, no database needed
  • Settings per hostname are stored in comments of dnsmasq config files
  • Very small image size (<20MB)

Setup

DNS

For OpenDynDNS to work you need to have a domain you can configure.

For example if you want to use the subdomain sub.example.com (so users can register [anything].sub.example.com) as root for your dyn DNS clients, and your OpenDynDNS instance is running on the IP 1.2.3.4 (which you want to access through the domain dyndns.example.com) you need to configure two DNS entries:

# zonefile for example.com
dyndns IN  A   1.2.3.4              # This is where the web interface will be (dyndns.example.com)
sub IN  NS  dyndns.example.com.  # the nameserver pointing to the machine running the docker container

API

All API calls need the secret in form of a HTTP header called SECRET or via POST/GET parameter called secret. The secret can be found in the web interface (unless you set the NO_SECRET config variable)

Endpoint Explanation API answer
/setip/yourhost.example.com Updates the IP of the hostname. If no POST vars are supplied, automatically detecting IP from request, if POST var ipv4 or ipv6 is provided, updates the host with these IPs OK updated [ip] or the corresponding error message
/clearips/yourhost.example.com Clears all IPs associated with this hostname OK or the corresponding error message
/renewsecret/yourhost.example.com Refreshes the secret and returns the new one the secret or the corresponding error message

Examples

Autodetecting IP and updating hostname my.example.com

curl http://localhost:8080/api/setip/my.example.com \
-H "secret:5dc2eff026f11b1e2ec537abba60c079b50fc495212622e6a76f05bcbed11794"

Supplying the IPv4 and IPv6 IPs in the request

curl http://localhost:8080/api/setip/my.example.com \
-H "secret:5dc2eff026f11b1e2ec537abba60c079b50fc495212622e6a76f05bcbed11794" \
--data "ipv4=1.1.1.1" \
--data "ipv6=2001:4860:4860::8888"

Clear IPs of my.example.com

curl http://localhost:8080/api/clearips/yes.example.com \
-H "secret:5dc2eff026f11b1e2ec537abba60c079b50fc495212622e6a76f05bcbed11794"

Configuration

Config Explanation Default
URL URL to the web UI. No tailing slash! http://localhost:8080
DOMAINS Comma separated list of domains which can be registered. Must have DNS records pointing to the containers DNS port example.com,sub.example.org
ALLOW_PRIVATE_IP Whether or not IPs in private ranges can be set (useful if you want to use OpenDynDNS as your LAN DNS) false
ALLOW_DYNAMIC_CREATION If set to true (default), the API will allow you to create new hostnames on the fly by calling the /setip endpoint. All further calls need the secret though true
NO_SECRET If set to true, all API calls can be used without the generated secret. Please only use in trusted LAN settings false

Docker environment vars

All config settings can be supplied to docker containers with the same name. Just with one addition:

env Explanation Default
DNS_OPENRESOLVE If set to true, dnsmasq will forward all unknown requests to cloudflare DNS servers. ONLY FOR LAN, NEVER EXPOSE AN OPEN RESOLVER TO THE INTERNET false