Lightweight, robust, and zero-dependency scripts to automatically update your dynamic IP address for DuckDNS.
This repository contains two scripts tailored for different environments:
- Windows: A modern PowerShell (7.6+) script utilizing
Invoke-RestMethodand the built-in Task Scheduler. - Linux / OpenWrt / Embedded: A strict POSIX-compliant
shscript relying oncurlorwgetand standardcron.
Both scripts feature built-in installation logic, meaning they can set themselves up to run silently in the background every 5 minutes with full logging capabilities.
Before running or installing either script, you MUST edit the files and replace the placeholder values with your actual DuckDNS details.
Open the scripts in a text editor and locate these exact lines at the top:
In both duckdns.ps1 and duckdns.sh:
Change "CHANGE_ME" to your actual DuckDNS subdomain, and "CHANGE_ME_TO" to your private DuckDNS token.
DOMAIN="CHANGE_ME" <-- e.g., "mycustomdomain" (without .duckdns.org)
TOKEN="CHANGE_ME_TO" <-- e.g., "a1b2c3d4-..."
(Alternatively, both scripts support passing these values as command-line arguments if you prefer not to hardcode them).
Requirements: PowerShell 7.6+ (pwsh.exe).
To test the script and update your IP immediately, simply run it:
.\duckdns.ps1To install the script so it runs silently in the background every 5 minutes regardless of who is logged in:
- Open PowerShell as Administrator.
- Run the script with the
-Installswitch:
.\duckdns.ps1 -InstallThis will create a hidden Scheduled Task running as the SYSTEM account. Logs are written to C:\ddns.log.txt by default.
You can override the hardcoded variables on the fly:
.\duckdns.ps1 -Domain "anotherdomain" -Token "your-token-here" -LogPath "D:\Logs\duckdns.txt"Requirements: curl or wget, and cron (Standard on almost all Linux/OpenWrt distributions).
Make the script executable:
chmod +x ./duckdns.shRun the script to update the IP and view the output directly in the terminal:
./duckdns.shTo install the script into the current user's crontab to run every 5 minutes:
./duckdns.sh --install(Note: If you want the log file to be saved in /var/log/ddns.log, you must run the installation with sudo, otherwise it will warn you about missing write permissions).
To safely remove the script from your crontab:
./duckdns.sh --uninstallThe bash script accepts standard flags to override the internal variables:
./duckdns.sh --domain "anotherdomain" --token "your-token-here" --log "/tmp/custom_log.txt"- Author: Andreas Nilsen (adde88@gmail.com)
- GitHub: adde88
- Copyright: © 2026