DDNS supports configuration through environment variables with the following priority order: Command Line Arguments > Configuration File > Environment Variables
All environment variables use the DDNS_ prefix followed by the parameter name (recommended uppercase).
export DDNS_xxx="xxx"command applies to the current hostdocker run -e DDNS_xxx="xxx"command applies to the container
| Environment Variable | Accepted Values | Description | Example |
|---|---|---|---|
DDNS_CONFIG |
File path, supports comma or semicolon-separated multiple paths | Specify config file path, supports multiple files | DDNS_CONFIG="config.json" or DDNS_CONFIG="cloudflare.json,dnspod.json" |
DDNS_DNS |
51dns, alidns, aliesa, callback, cloudflare, debug, dnscom, dnspod_com, dnspod, edgeone, he, huaweidns, noip, tencentcloud |
DNS Provider | DDNS_DNS=cloudflare |
DDNS_ID |
Depends on the provider | API account or ID | DDNS_ID="[email protected]" |
DDNS_TOKEN |
Depends on the provider | API token or secret | DDNS_TOKEN="abcdef123456" |
DDNS_ENDPOINT |
URL (starting with http or https) | Custom API endpoint | DDNS_ENDPOINT=https://api.dns.cn |
DDNS_IPV4 |
Domains as array or comma-separated string | List of IPv4 domains | DDNS_IPV4='["t.com","4.t.com"]' |
DDNS_IPV6 |
Domains as array or comma-separated string | List of IPv6 domains | DDNS_IPV6=t.com,6.t.com |
DDNS_INDEX4 |
Number, default, public, url:, regex:, cmd:, shell:, or an array of them |
IPv4 address detection methods | DDNS_INDEX4="[0,'regex:192.168.*']" |
DDNS_INDEX6 |
Number, default, public, url:, regex:, cmd:, shell:, or an array of them |
IPv6 address detection methods | DDNS_INDEX6=public |
DDNS_TTL |
Integer (seconds), varies by provider | DNS record TTL | DDNS_TTL=600 |
DDNS_LINE |
ISP line such as: 电信, 联通, 移动, or provider-specific values | DNS resolution line | DDNS_LINE=电信 |
DDNS_PROXY |
IP:port or DIRECT, multiple values separated by semicolons |
HTTP proxy settings | DDNS_PROXY="127.0.0.1:1080;DIRECT" |
DDNS_CACHE |
true, false, or file path |
Enable or specify cache file | DDNS_CACHE="/tmp/cache" |
DDNS_SSL |
true, false, auto, or file path |
SSL verification mode or certificate path | DDNS_SSL=falseDDNS_SSL=/path/ca.crt |
DDNS_LOG_LEVEL |
DEBUG, INFO, WARNING, ERROR, CRITICAL |
Logging level | DDNS_LOG_LEVEL="DEBUG" |
DDNS_LOG_FILE |
File path | Output log file (default: stdout) | DDNS_LOG_FILE="/tmp/ddns.log" |
DDNS_LOG_FORMAT |
Python logging format string | Log format template | DDNS_LOG_FORMAT="%(message)s" |
DDNS_LOG_DATEFMT |
Date-time format string | Log timestamp format | DDNS_LOG_DATEFMT="%m-%d %H:%M" |
config.json, ~/.ddns/config.json, etc.)Examples:
# Single configuration file
export DDNS_CONFIG="config.json"
export DDNS_CONFIG="/path/to/ddns.json"
# Multiple configuration files
export DDNS_CONFIG="/etc/ddns/cloudflare.json,./dnspod.json"
Examples:
# Cloudflare (email address)
export DDNS_ID="[email protected]"
# DNSPod (numeric ID)
export DDNS_ID="12345"
# Alibaba Cloud (Access Key ID)
export DDNS_ID="LTAI4xxxxxxxxxxxxx"
# HE.net (can be empty)
export DDNS_ID=""
Examples:
# General API token
export DDNS_TOKEN="abcdef1234567890"
# Cloudflare API token
export DDNS_TOKEN="1234567890abcdef_example_token"
# Alibaba Cloud Secret Key
export DDNS_TOKEN="secretkey1234567890"
dnspod51dns, alidns, aliesa, callback, cloudflare, debug, dnscom, dnspod, dnspod_com, edgeone, he, huaweidns, noip, tencentcloudExamples:
export DDNS_DNS="cloudflare"
export DDNS_DNS="alidns"
export DDNS_DNS="dnspod"
Examples:
# Custom Cloudflare endpoint
export DDNS_ENDPOINT="https://api.private-cloudflare.com"
# Private DNSPod deployment
export DDNS_ENDPOINT="https://internal-dns-api.company.com"
# Local testing endpoint
export DDNS_ENDPOINT="http://localhost:8080/api"
When using DDNS_DNS="callback", configure custom callbacks with these environment variables:
For detailed configuration, see: Callback Provider Configuration Documentation
Examples:
# GET method callback
export DDNS_DNS="callback"
export DDNS_ID="https://api.example.com/ddns?domain=__DOMAIN__&ip=__IP__"
export DDNS_TOKEN=""
# POST method callback (JSON string)
export DDNS_DNS="callback"
export DDNS_ID="https://api.example.com/ddns"
export DDNS_TOKEN='{"api_key": "your_key", "domain": "__DOMAIN__", "ip": "__IP__"}'
Supported Variable Substitutions:
__DOMAIN__: Full domain name__IP__: IP address (IPv4 or IPv6)__RECORDTYPE__: DNS record type__TTL__: Time to live (seconds)__LINE__: Resolution line__TIMESTAMP__: Current timestamp[]Examples:
# JSON array format (recommended)
export DDNS_IPV4='["example.com", "www.example.com", "api.example.com"]'
# Python list format
export DDNS_IPV4="['example.com', 'www.example.com']"
# Comma-separated string
export DDNS_IPV4="example.com,www.example.com"
# Single domain
export DDNS_IPV4="example.com"
[]Examples:
# JSON array format
export DDNS_IPV6='["example.com", "ipv6.example.com"]'
# Comma-separated string
export DDNS_IPV6="example.com,ipv6.example.com"
# Single domain
export DDNS_IPV6="ipv6.example.com"
["default"] (uses system's default external IP), or semicolon ; separated string formatregex:, cmd:, or shell: prefix, separator splitting is not supported; the entire string is treated as a single configuration itemExamples:
# Use public IP detection
export DDNS_INDEX4="public"
# Multiple methods with fallback
export DDNS_INDEX4='["public", "default"]'
# Network interface index
export DDNS_INDEX4="0" # First network interface
export DDNS_INDEX4="1" # Second network interface
# Custom URL
export DDNS_INDEX4="url:https://api.ipify.org"
# Regex pattern (no splitting)
export DDNS_INDEX4="regex:192\\.168\\..*"
# Command execution (no splitting)
export DDNS_INDEX4="cmd:hostname -I | awk '{print \$1}'"
# Shell command (no splitting)
export DDNS_INDEX4="shell:ip route get 8.8.8.8 | awk '{print \$7}'"
["default"] (uses system's default external IPv6)Examples:
# Use public IPv6 detection
export DDNS_INDEX6="public"
# Network interface index
export DDNS_INDEX6="0"
# Custom IPv6 detection URL
export DDNS_INDEX6="url:https://api6.ipify.org"
# Multiple methods
export DDNS_INDEX6='["public", "default"]'
Examples:
# 5 minutes
export DDNS_TTL="300"
# 10 minutes (commonly used)
export DDNS_TTL="600"
# 1 hour
export DDNS_TTL="3600"
Examples:
# Default line
export DDNS_LINE="default"
# China Telecom
export DDNS_LINE="telecom"
# China Unicom
export DDNS_LINE="unicom"
# China Mobile
export DDNS_LINE="mobile"
# Overseas
export DDNS_LINE="overseas"
Examples:
# Single proxy
export DDNS_PROXY="127.0.0.1:1080"
# Multiple proxies with fallback
export DDNS_PROXY="127.0.0.1:1080;127.0.0.1:8080;DIRECT"
# JSON array format
export DDNS_PROXY='["127.0.0.1:1080", "DIRECT"]'
# SOCKS proxy
export DDNS_PROXY="socks5://127.0.0.1:1080"
# HTTP proxy with authentication
export DDNS_PROXY="http://user:[email protected]:8080"
trueExamples:
# Enable cache (default location)
export DDNS_CACHE="true"
# Disable cache
export DDNS_CACHE="false"
# Custom cache file path
export DDNS_CACHE="/var/cache/ddns/cache.json"
# Use temporary directory
export DDNS_CACHE="/tmp/ddns.cache"
INFODEBUG, INFO, WARNING, ERROR, CRITICALExamples:
# Debug mode (most verbose)
export DDNS_LOG_LEVEL="DEBUG"
# Normal operation
export DDNS_LOG_LEVEL="INFO"
# Warnings only
export DDNS_LOG_LEVEL="WARNING"
# Errors only
export DDNS_LOG_LEVEL="ERROR"
Examples:
# System log directory
export DDNS_LOG_FILE="/var/log/ddns.log"
# User home directory
export DDNS_LOG_FILE="$HOME/ddns.log"
# Temporary directory
export DDNS_LOG_FILE="/tmp/ddns.log"
%(asctime)s %(levelname)s [%(module)s]: %(message)sExamples:
# Simple format
export DDNS_LOG_FORMAT="%(asctime)s: %(message)s"
# Detailed format
export DDNS_LOG_FORMAT="%(asctime)s [%(levelname)s] %(name)s: %(message)s"
# JSON format
export DDNS_LOG_FORMAT='{"time": "%(asctime)s", "level": "%(levelname)s", "message": "%(message)s"}'
%Y-%m-%dT%H:%M:%SExamples:
# ISO format (default)
export DDNS_LOG_DATEFMT="%Y-%m-%dT%H:%M:%S"
# Standard format
export DDNS_LOG_DATEFMT="%Y-%m-%d %H:%M:%S"
# Short format
export DDNS_LOG_DATEFMT="%m/%d %H:%M:%S"
# Basic Cloudflare configuration
export DDNS_DNS="cloudflare"
export DDNS_ID="[email protected]"
export DDNS_TOKEN="your_cloudflare_token"
export DDNS_IPV4="example.com"
# Advanced configuration with multiple domains and custom settings
export DDNS_DNS="cloudflare"
export DDNS_TOKEN="your_api_token"
export DDNS_IPV4='["example.com", "www.example.com", "api.example.com"]'
export DDNS_IPV6='["ipv6.example.com"]'
export DDNS_INDEX4="public"
export DDNS_INDEX6="public"
export DDNS_TTL="600"
export DDNS_PROXY="127.0.0.1:1080;DIRECT"
export DDNS_CACHE="/var/cache/ddns.json"
export DDNS_LOG_LEVEL="DEBUG"
export DDNS_LOG_FILE="/var/log/ddns.log"
export DDNS_DNS="dnspod"
export DDNS_ID="12345"
export DDNS_TOKEN="your_dnspod_token"
export DDNS_IPV4="example.com"
export DDNS_LINE="默认"
export DDNS_DNS="alidns"
export DDNS_ID="LTAI4xxxxxxxxxxxxx"
export DDNS_TOKEN="your_secret_key"
export DDNS_IPV4="example.com"
export DDNS_LINE="default"
export DDNS_DNS="callback"
export DDNS_ID="https://api.example.com/webhook?domain=__DOMAIN__&ip=__IP__"
export DDNS_TOKEN=""
export DDNS_IPV4="example.com"
DDNS also supports some standard environment variables commonly used in system environments:
| Standard Variable | DDNS Equivalent | Description |
|---|---|---|
HTTP_PROXY |
DDNS_PROXY |
HTTP proxy server |
HTTPS_PROXY |
DDNS_PROXY |
HTTPS proxy server |
NO_PROXY |
- | Bypass proxy for these hosts |
PYTHONHTTPSVERIFY |
DDNS_SSL |
Python HTTPS verification |
Note: DDNS-specific variables take priority over standard environment variables.
When using environment variables, DDNS will validate the configuration and provide error messages for invalid values: