An intelligent DNS update tool designed for dynamic IP servers. Automatically triggers server IP changes when client heartbeat times out, ensuring continuous service availability.
- Automatically fetches current IP and updates Cloudflare DNS
- Supports multiple IP service URLs with automatic failover
- Supports various IP response formats (plain text, JSON, etc.)
- Listens for client heartbeats using reliable TCP protocol
- Automatically changes IP after heartbeat timeout with exponential backoff strategy
- Monitors IP changes every minute and updates DNS automatically
- Comprehensive logging with log rotation
- Sends TCP heartbeat to server every 30 seconds
- Automatic reconnection and error handling
- Heartbeat success rate statistics
- Logging support with rotation
- Debian/Ubuntu system
- Python 3.6+
- pip3
- systemd
-
Clone or download this project to your server
-
Install server:
sudo ./install.sh server
-
Edit configuration file
/etc/ddns/server_config.yaml:domain: your-subdomain.example.com cf_email: your-email@example.com cf_key: your-cloudflare-api-key get_ip_url: http://your-ip-service.com/get_ip change_ip_url: http://your-ip-service.com/change_ip port: 8888 heartbeat_timeout: 180
-
Start service:
sudo systemctl start ddns-server sudo systemctl enable ddns-server
-
Clone or download this project to client machine
-
Install client (replace your-server.com with actual domain):
sudo ./install.sh client your-server.com 8888
-
Start service:
sudo systemctl start ddns-client sudo systemctl enable ddns-client
domain: Domain to update (must be managed by Cloudflare)cf_email: Cloudflare account emailcf_key: Cloudflare API key (global API key)get_ip_url: API URL to get current IP, supports:- Single URL string:
get_ip_url: http://your-ip-service.com/get_ip - URL list (tries in order):
get_ip_url: - http://your-ip-service.com/get_ip - https://api.ipify.org - http://ip.42.pl/raw
- Supports various formats: plain IP text, JSON format, etc., automatically extracts IP address
- Single URL string:
change_ip_url: API URL to change IPport: TCP listening port (default 8888)heartbeat_timeout: Heartbeat timeout in seconds (default 180)ttl: DNS A record TTL in seconds (default 60)log_dir: Log file directory (default /var/log/ddns)debug: Enable debug logging (default false)
- Login to Cloudflare
- Go to Profile -> API Tokens
- View Global API Key
# Check status
sudo systemctl status ddns-server
# View logs
sudo journalctl -u ddns-server -f
# Restart service
sudo systemctl restart ddns-server# Check status
sudo systemctl status ddns-client
# View logs
sudo journalctl -u ddns-client -f
# Restart service
sudo systemctl restart ddns-client- Server fetches current IP on startup and updates DNS record
- Server listens on TCP port for client heartbeat connections
- Client establishes TCP connection every 30 seconds to send heartbeat, server responds with acknowledgment
- If no heartbeat received within 3 minutes, server requests IP change
- After IP change, uses exponential backoff strategy (3 minutes, 6 minutes, 12 minutes... up to 24 hours)
- Server checks for IP changes every minute and updates DNS automatically
- All operations are logged to files with rotation support
- Server logs:
/var/log/ddns/ddns_server.log - Client logs:
/var/log/ddns/ddns_client.log - Automatic log rotation: server keeps 5 files (10MB each), client keeps 3 files (5MB each)
- Check if Python dependencies are installed completely
- Verify configuration file permissions (should be 600)
- Check if firewall allows TCP port (default 8888)
- View log files for detailed error information:
# Real-time server logs tail -f /var/log/ddns/ddns_server.log # Real-time client logs tail -f /var/log/ddns/ddns_client.log