Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-ddns (dynamic DNS client)

Requirements:

  • cargo
  • dnsutils

Installation

Installation is built into the binary via rust-ddns install and rust-ddns uninstall subcommands. First build the binary with cargo build --release, then run it once to install:

Linux (systemd)

cargo build --release
./target/release/rust-ddns install
# or with a custom interval:
./target/release/rust-ddns install --interval 30min

Then activate the timer:

sudo systemctl enable --now rust-ddns.timer

macOS (launchd)

cargo build --release
./target/release/rust-ddns install --interval 30min

The LaunchAgent is installed at ~/Library/LaunchAgents/com.rust-ddns.plist and loaded automatically.

Windows (Task Scheduler)

cargo build --release
.\target\release\rust-ddns.exe install --interval 30min

Uninstall

rust-ddns uninstall
# Remove config and log files as well:
rust-ddns uninstall --purge

The default interval is 5min on all platforms.

Debugging

Set log level to debug:

export DDNS_LOG_LEVEL=debug

Configuration

Default config file (not created automatically): $HOME/.ddns.conf

Custom config path with option -c/--config-file e.g.

DDNS_LOG_LEVEL=debug rust-ddns --config-file ./my.conf

Config file is in yaml format, and must include the following properties:

server: my.dns.provider.com
domain: ddns.domain.com
methods:
    - DELETE
    - POST
    - PUT
records:                    # optional, defaults to A
    - A
    - AAAA
username: api-key/username
password: api-secret/password
---                         # multiple configs split by line break
server: my.other.dns.provider
domain: my.other.domain.com
...  

The above example config would make 6 calls to the same server, one for each method for each record type. You can provide between 1 and 3 methods, either PUT, POST, or DELETE.

Cloudflare

Google Domains DDNS (domains.google.com) is no longer supported — Google sold Domains to Squarespace, which dropped DDNS support. Migrate to Cloudflare:

server: cloudflare
domain: ddns.example.com
api_token: env:CF_API_TOKEN
records:
    - A
  • server: cloudflare enables the Cloudflare protocol
  • api_token is required (plain text or env: reference); username and password are not used
  • Zone ID and record ID are resolved automatically from the domain name
  • methods is not required for Cloudflare configs

Migration steps:

  1. Transfer your domain to Cloudflare (or add it as a DNS zone)
  2. Create a Cloudflare API token with Zone:DNS:Edit permission
  3. Update your config to use server: cloudflare and api_token

Namecheap

server: namecheap
domain: host.example.com
password: env:NAMECHEAP_DDNS_PASSWORD
records:
    - A
  • server: namecheap enables the Namecheap DDNS protocol
  • password is the Namecheap DDNS password (plain text or env: reference); username is not used
  • Only A records are supported (AAAA is not supported by Namecheap DDNS)
  • The host portion is extracted from the domain automatically (e.g. host from host.example.com)
  • For apex domains, set domain: example.com and the host will be sent as @

Secure Credential Storage

Passwords (and usernames) can be read from environment variables at runtime using the env: prefix:

password: env:MY_SECRET_VAR
  • password: env:MY_VAR resolves the value from environment variable MY_VAR at runtime
  • If the variable is unset or empty, the app exits with an error
  • Plain text passwords still work unchanged
  • Recommended: use a systemd EnvironmentFile to supply secrets without writing them to disk

Example systemd service drop-in (/etc/systemd/system/rust-ddns.service.d/secrets.conf):

[Service]
EnvironmentFile=/etc/rust-ddns/secrets

Where /etc/rust-ddns/secrets contains:

MY_SECRET_VAR=your-api-key-here

About

Client to dynamically update DNS records. Works with MiaB (mailinabox) ddns API, and the (now deprecated) Google Domains API.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages