ds

ddns-server

A Dynamic DNS API server and Nameserver and Web Interface

Showing:

Popularity

Downloads/wk

1

Maintenance

No Maintenance Data Available

Package

Dependencies

12

License

(MIT OR Apache-2.0)

Type Definitions

Tree-Shakeable

No?

Categories

Node.js DNS API

Readme

| ddnsd | ddns-server | ddns-client |

ddns-server

A Dynamic DNS (DDNS / DynDNS) server written in node.js.

This server is capable of all of the following:

  • static dns
  • dynamic dns
  • device dns
  • multiple device dynamic dns

This module consists of 3 plugins:

  • ddns-rest (external https APIs, typically https port 443)
  • ddns-nameserver (nameserver implementation, typically udp/tcp ports 53)
  • ddns-webapp (web interface, typically https port 443)

Install

Commandline

See ddnsd and ddns

Casual

# Core Library
npm install --save ddns-server

# Default Plugins
npm install --save ddns-rest
npm install --save ddns-nameserver
npm install --save ddns-webapp

For Development

git clone git@github.com:Daplie/node-ddns.git
pushd node-ddns/

mkdir node_modules/
git clone git@github.com:Daplie/ddns-rest.git node_modules/ddns-rest
git clone git@github.com:Daplie/ddns-nameserver.git node_modules/ddns-nameserver
git clone git@github.com:Daplie/ddns-webapp.git node_modules/ddns-webapp

Usage

Here's how to create your own nameserver and ddns api using only the default plugins.

'use strict';

require('ddns-server').create({
  dnsPort: 53
, httpPort: 80
, filepath: path.join(require('os').homedir(), '.ddnsd.sqlite3')
, primaryNameserver: 'ns1.example.com'
, nameservers: [
    { name: 'ns1.example.com', ipv4: '192.168.1.101' }
  , { name: 'ns2.example.com', ipv4: '192.168.1.102' }
  ]
}).listen();

Walkthrough

You can follow this example verbatim and get working results.

There are three steps:

  1. Create a token for a domain and a device
  2. Set a device record
  3. Update the device's ip

Create a Token

The device represents a physical device, like a server, Digital Ocean droplet, VPS, your laptop, or a Raspberry Pi

The domain is a domain the device is allowed to modify.

# node bin/ddns-jwtgen.js <<private key>> <<domain>> <<device name>>
node bin/ddns-jwtgen.js ./privkey.pem example.com digital-ocean-server-1 > srv1-example-com.jwt

Example: A record

curl 'http://localhost:80/api/com.daplie.ddns/dns' \
  -X POST \
  -H "Authorization: Bearer $(cat srv1-example-com.jwt)" \
  -H "Content-Type: application/json; charset=UTF-8" \
  -d '[
    { "registered": true
    , "groupIdx": 1
    , "type": "A"
    , "name": "example.com"
    , "device": "digital-ocean-server-1"
    , "value": "127.0.0.1"
    , "ttl": 600
    , "token": "$(cat srv1-example-com.jwt)"
    }
  ]'

And test

dig @127.0.0.1 example.com

Note: Yes, token is used twice, but that's just a workaround for a current problem.

Note: value will default to the IP address of the connecting client

Note: You can add multiple records for the same DNS host with various devices. This means that some clients will pick any available record at random or will access each device round-robin style.

Update a device IP

All A (and AAAA, if specified) records associated with the device digital-ocean-server-1 will be updated with the supplied IP addresses:

curl 'http://localhost:80/api/com.daplie.ddns/devices' \
  -X POST \
  -H "Authorization: Bearer $(cat srv1-example-com.jwt)" \
  -H "Content-Type: application/json; charset=UTF-8" \
  -d '{
        "name": "digital-ocean-server-1"
      , "addresses": [ { "type": "A", "value": "127.0.0.1" } ]
      }'

Note: groupIdx must exist and token and be the same as set in the dns record

Example: other records

curl 'http://localhost:80/api/com.daplie.ddns/dns' \
  -X POST \
  -H "Authorization: Bearer $(cat srv1-example-com.jwt)" \
  -d '[
    { "registered": true
    , "groupIdx": 1
    , "type": "CNAME"
    , "name": "www.example.com"
    , "value": "example.com"
    , "ttl": 600
    , "token": "'$(cat srv1-example-com.jwt)'"
    }
  ]'

Note: Yes, token is used twice, but that's just a workaround to another bug.

Note: MX records have the additional option priority.

License

MIT + Apache2

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Tutorials

No tutorials found
Add a tutorial